javax.persistence.PersistenceException: No ScalarType registered for class blah.User$$EntityBean$warp

1,258 views
Skip to first unread message

Edmundo Carmona Antoranz

unread,
Feb 23, 2013, 1:28:29 AM2/23/13
to eb...@googlegroups.com
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.

Rob Bygrave

unread,
Feb 23, 2013, 4:24:10 AM2/23/13
to eb...@googlegroups.com
Instead of :

.eq(FIELD_USER, user)

Try:

.eq("user.id", user.getId());


--
 
---
You received this message because you are subscribed to the Google Groups "Ebean ORM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ebean+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Edmundo Carmona Antoranz

unread,
Feb 23, 2013, 7:22:36 AM2/23/13
to eb...@googlegroups.com
Thanks for your response, Rob, changing to user.getId() pulls it off but this is fairly interesting. Why do I have to compare with user.getId() but can use permission as is?


    public static boolean userHasPermission(User user, Permission permission) {
        return Ebean.find(PermissionByUser.class).where()
                .eq(FIELD_USER, user.getId())
                .eq(FIELD_PERMISSION, permission).findRowCount() > 0;
    }

Reply all
Reply to author
Forward
0 new messages