Forums Register Login

Exception setting property value with CGLIB

+Pie Number of slices to send: Send
I have an User table in my MySQL database. I changed one column of that table from STATUS(varchar) to ISACTIVE(boolean).

Now when I call any getter method of the User bean, which corresponds to the User table, I get following exception:

exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.bean.Expert.setIsActive

What can be the reason for this?

I have appropriately chaned the user.hbm.xml file and User.java bean class

Thanks in advance
+Pie Number of slices to send: Send
Please post your mapping and bean code, using the CODE button below, so that the code keeps its indentations.

I am sure it is probably one simple change.

so if your field is called isactive, and if you called your attribute isActive, then wouldn't that then make your method isIsActive?

Mark
+Pie Number of slices to send: Send
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

Code for user.hbm.xml


Code for User.java (Bean)

+Pie Number of slices to send: Send
 

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 )
+Pie Number of slices to send: Send
 

Originally posted by Jaikiran Pai:


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.
+Pie Number of slices to send: Send
Please also post your hibernate.cfg.xml file

I see you also have another boolean field



Totally un-related, but why were the database field names have the "is" in front of the name, why not just PAID_USER?

Mark
1
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
Hi

I am also facing the same issue.

Here is the code snippet

The main java class.



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

 
+Pie Number of slices to send: Send
 

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!
1
+Pie Number of slices to send: Send
Hi

What changes that you have done to fix this issue as suggested by Pranav Pal in previous reply that he has fixed by making that as wrapper.

Thanks
+Pie Number of slices to send: Send
 

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
+Pie Number of slices to send: Send
 

Ragupathirajan Venkatesan wrote:Hi

What changes that you have done to fix this issue as suggested by Pranav Pal in previous reply that he has fixed by making that as wrapper.

Thanks



I changed this:



to this:


There is no "i" in denial. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 13279 times.
Similar Threads
Strange Hibernate exception with CGLIB
JPA-hibernate-spring config
Hibernate Error - "exception setting property value with CGLIB"
Hibernate: How to map int type if column is Null able
PropertyAccessException using spring and hibernate, any clues?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:56:34.