Hi!
I'm setting up this table where I relate users and their permissions. I'm working with the DB creating the tables by hand and then creating entities for them alongside. It has worked like a charm till now.
The entities I'm working at the moment are:
- User
- Permission
- PermissionByUser
Both User and Permission have their @Id fields sets (in both cases it's an int). Then I created PermissionByUser where I relate User and Permission. I set up the fields for them like this:
@ManyToOne
@JoinColumn(name = FIELD_USER)
private User user;
@ManyToOne
@JoinColumn(name = FIELD_PERMISSION)
private Permission permission;
I don't set any relationship back (@OneToMany) either in User or Permission (and perhaps that's the source of the problem, you'll tell me). The relationship is _only_ defined in PermissionByUser.
Now, when I try to check if a user has set a given permission I do it like this (in PermissionByUser):
public static boolean userHasPermission(User user, Permission permission) {
return Ebean.find(PermissionByUser.class).where().eq(FIELD_USER, user)
.eq(FIELD_PERMISSION, permission).findRowCount() > 0;
}
But I get this exception when I try to run it:
javax.persistence.PersistenceException: No ScalarType registered for class warpt.central.entities.admin.User$$EntityBean$warp
com.avaje.ebeaninternal.server.persist.Binder.bindObject(Binder.java:183)
com.avaje.ebeaninternal.server.query.CQueryPredicates.bind(CQueryPredicates.java:162)
com.avaje.ebeaninternal.server.query.CQueryRowCount.findRowCount(CQueryRowCount.java:145)
com.avaje.ebeaninternal.server.query.CQueryEngine.findRowCount(CQueryEngine.java:120)
com.avaje.ebeaninternal.server.query.DefaultOrmQueryEngine.findRowCount(DefaultOrmQueryEngine.java:55)
com.avaje.ebeaninternal.server.core.OrmQueryRequest.findRowCount(OrmQueryRequest.java:285)
com.avaje.ebeaninternal.server.core.DefaultServer.findRowCountWithCopy(DefaultServer.java:1372)
com.avaje.ebeaninternal.server.core.DefaultServer.findRowCount(DefaultServer.java:1364)
com.avaje.ebeaninternal.server.querydefn.DefaultOrmQuery.findRowCount(DefaultOrmQuery.java:933)
com.avaje.ebeaninternal.util.DefaultExpressionList.findRowCount(DefaultExpressionList.java:185)
blah.PermissionByUser.userHasPermission(PermissionByUser.java:63)
etc
etc
What am I missing? Thanks in advance.