6

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?

Tiago Sippert
  • 1,324
  • 7
  • 24
  • 33
user1143343
  • 255
  • 1
  • 5
  • 14

1 Answers1

10

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

Jama A.
  • 15,680
  • 10
  • 55
  • 88
  • i've actually had the same issue, and the solution was, as Jamshid Asatillayev sais, to change my boolean to Boolean (so it will accept null). Also, if you have constrains such as nullable=false, make sure to remove those as well. – Shivan Dragon Jan 30 '12 at 17:01