Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception setting property value with CGLIB

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?

like image 390
user1143343 Avatar asked Jan 30 '12 16:01

user1143343


1 Answers

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...

like image 182
Jama A. Avatar answered Sep 20 '22 04:09

Jama A.