I have changed attribute name to "active" and getter/setter methods are now isActive() and setActive()
Still I am geting exception: org.hibernate.PropertyAccessException:exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.bean.User.setActive
Originally posted by Pranav Pal: I changed one column of that table from STATUS(varchar) to ISACTIVE(boolean).
I don't know, how you have changed the column definition. But have you also ensured that when you changed the column from varchar to boolean, you even cleared off this column contents (might be dumb question, if the database already takes care of clearing the contents of the column when you change its schema definition )
I don't know, how you have changed the column definition. But have you also ensured that when you changed the column from varchar to boolean, you even cleared off this column contents (might be dumb question, if the database already takes care of clearing the contents of the column when you change its schema definition )
I didn't need to change the contents as the values for STATUS was NULL in all the tuples.
I have found that the reason why I was getting exception was that I had mapped a primitive property (active - boolean) to a nullable column (ISACTIVE). Since primitives cannot be null, one cannot map it to a nullable ccolumn. I was not getting the same excpetion for isPaidUser because the type declared for isPaidUser was Boolean (Wrapper class) and not boolean (primitive).
The ProductFamily pojo mapped to PRODUCT_FAMILY table
The ProductAlive pojo mapped to PRODUCTS_ALIVE table
PRODUCT_FAMILY has one to many relationship with PRODUCTS_ALIVE table
PROUDCTS_ALIVE has three primary keys(Composite primary keys).
The corresponding separate pojo ProductAliveKey representing it.
HBM files
ProductFamily.hbm.xml
ProductAlive.hbm.xml
The database structure
I am getting following exception when i try to run main class.
org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.deere.domain.ProductFamily.setProductAliveList
at org.hibernate.tuple.PojoEntityTuplizer.setPropertyValuesWithOptimizer(PojoEntityTuplizer.java:215)
at org.hibernate.tuple.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:185)
at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3232)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:253)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:114)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:559)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:547)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:543)
at com.deere.hibernate.ProductMaintain.main(ProductMaintain.java:46)
Caused by: net.sf.cglib.beans.BulkBeanException: org.hibernate.collection.PersistentBag incompatible with java.util.ArrayList
at com.deere.domain.ProductFamily$$BulkBeanByCGLIB$$29c24265.setPropertyValues(<generated>)
at org.hibernate.tuple.PojoEntityTuplizer.setPropertyValuesWithOptimizer(PojoEntityTuplizer.java:212)
... 14 more
Caused by: java.lang.ClassCastException: org.hibernate.collection.PersistentBag incompatible with java.util.ArrayList
... 16 more
Pranav Pal wrote:I have found that the reason why I was getting exception was that I had mapped a primitive property (active - boolean) to a nullable column (ISACTIVE). Since primitives cannot be null, one cannot map it to a nullable ccolumn. I was not getting the same excpetion for isPaidUser because the type declared for isPaidUser was Boolean (Wrapper class) and not boolean (primitive).
This is why living in the future is so great: I can benefit from your having had this problem and posting about its solution. As a result I spent 20 minutes on a fix rather than hours trying to figure it out. Thank you!
Pranav Pal wrote:I have found that the reason why I was getting exception was that I had mapped a primitive property (active - boolean) to a nullable column (ISACTIVE). Since primitives cannot be null, one cannot map it to a nullable ccolumn. I was not getting the same excpetion for isPaidUser because the type declared for isPaidUser was Boolean (Wrapper class) and not boolean (primitive).
Thank you Mark and Jaikiran for your help
Me found the same error and fixed using method mentioned by Pranav , Just changed int to Integer and its all fixed. Thanks Pranav