문제

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!

도움이 되었습니까?

해결책

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()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top