Exception setting property value with CGLIB

user1143343 picture user1143343 · Jan 30, 2012 · Viewed 7.2k times · Source

After attaching newly backuped database, I'm getting an exception:

Caused by: org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.mytest.User.setPrimaryAccount

In my User class, I have these fields:

...

    private boolean isPrimaryAccount;

    public boolean getPrimaryAccount() {
        return isPrimaryAccount;
    }

    public void setPrimaryAccount(boolean primaryAccount) {
        isPrimaryAccount = primaryAccount;
    }

...

And exception referencing to here, from what it started giving an exception?

Answer

Õzbek picture Õzbek · Jan 30, 2012

After attaching newly backuped database

I think, you have nullable column in your database table and you are using primitve type boolean( which cannot be set to null) in your persistent class. I think this is the reason why you are getting this exception.

Hibernate recommends you:

We recommend that you declare consistently-named identifier properties on persistent classes and that you use a nullable (i.e., non-primitive) type.

Change boolean into Boolean, This may help...