Chris F.
Chris F.

Reputation: 501

Ebean + Play 2.0 Queries

When I have:

public class User extends Model {

    @Id
    public Long id;

    @Constraints.Required
    @Formats.NonEmpty
    public String username;

public String firstName; public String lastName;

can I do User.find.byUsername("myusername") or User.find.byFirstNameAndLastName... or would I have to define the method in the User class?

Thank you!

Upvotes: 0

Views: 1903

Answers (1)

Julien Lafont
Julien Lafont

Reputation: 7877

There is no "magic" method in PlayFramework2 (ok, in reality there is just "less" magic methods)

So you need to define these functions, or to use a composed statement.

User.find.where().eq("username", myUserName).findUnique()
User.find.where().eq("firstname", firstname).eq("lastname", lastname).findList()

Upvotes: 6

Related Questions