I have Role entity class:
@Entity public class Role extends Model { @Id @Constraints.Required public Integer id; @Constraints.Required @Formats.NonEmpty @Enumerated(EnumType.STRING) public RoleNameEnum name; // name is enum value }
In some test I try to find users by role:
List<User> users = User.findByRole(Role.findByRoleName(RoleNameEnum.ADMIN));
where method findByRoleName()
is following:
public static List<User> findByRole(Role role) { return find.where().eq("role", role).findList(); }
I receive error:
[error] Test UserTest.findUsersByRole failed: No ScalarType registered for class models.Role [error] at com.avaje.ebeaninternal.server.persist.Binder.bindObject(Binder.java:183) [error] at com.avaje.ebeaninternal.server.query.CQueryPredicates.bind(CQueryPredicates.java:162) [error] at com.avaje.ebeaninternal.server.query.CQuery.prepareBindExecuteQuery(CQuery.java:413) [error] at com.avaje.ebeaninternal.server.query.CQueryEngine.findMany(CQueryEngine.java:198) [error] at com.avaje.ebeaninternal.server.query.DefaultOrmQueryEngine.findMany(DefaultOrmQueryEngine.java:104) [error] at com.avaje.ebeaninternal.server.core.OrmQueryRequest.findList(OrmQueryRequest.java:344) [error] at com.avaje.ebeaninternal.server.core.DefaultServer.findList(DefaultServer.java:1469) [error] at com.avaje.ebeaninternal.server.querydefn.DefaultOrmQuery.findList(DefaultOrmQuery.java:906) [error] at com.avaje.ebeaninternal.util.DefaultExpressionList.findList(DefaultExpressionList.java:201) [error] at models.User.findByRole(User.java:63) [error] at UserTest$4.run(UserTest.java:62) [error] at play.test.Helpers.running(Helpers.java:294) [error] at UserTest.findUsersByRole(UserTest.java:58)
Does anybody have an idea what might be a problem?