aspose file tools*
The moose likes Object Relational Mapping and the fly likes org.hibernate.PropertyAccessException: exception setting property value with CGLIB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "org.hibernate.PropertyAccessException: exception setting property value with CGLIB " Watch "org.hibernate.PropertyAccessException: exception setting property value with CGLIB " New topic
Author

org.hibernate.PropertyAccessException: exception setting property value with CGLIB

Prashant Langade
Ranch Hand

Joined: Jul 01, 2009
Posts: 71
Hi

I am facing same strange 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


Can anyone please help me where am i going wrong?

Thanks and Regards
Prashant
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

This is the problem:
org.hibernate.collection.PersistentBag incompatible with java.util.ArrayList

If you want to use an ArrayList then you will need to change your mapping file so that it is mapped as a list and not as a bag.

Sean


I love this place!
Prashant Langade
Ranch Hand

Joined: Jul 01, 2009
Posts: 71
Thanks a lot for replying Sean,

But we can map a Bag for ArrayList.

Because there is no concept of Bag in Java.it is just the hibernate data type.

Please have a look at this Bag example

Here you can see that they have shown that Bag can be mapped with java.util.ArrayList

Prashant Langade
Ranch Hand

Joined: Jul 01, 2009
Posts: 71
Hi Sean,

I did some modification to the code and now i can see the queries getting executed.

Here are the modifications done.






Here is the exception

INFO: Not binding factory to JNDI, no JNDI name configured
Hibernate: insert into ADRPTMT.PRODUCT_FAMILY (PRODUCT_FAMILY_DSC, ANNUAL_USAGE_HRS_TM, MACHINES_PER_CATALOG_CNT, PRODUCT_FAMILY_ID) values (?, ?, ?, ?)
Hibernate: update ADRPTMT.PRODUCTS_ALIVE set PRODUCT_FAMILY_ID=? where PRODUCT_FAMILY_ID=? and PARTS_CATALOG_NUM=? and ALIVE_YR=?
Apr 14, 2011 4:20:15 PM org.hibernate.type.NullableType nullSafeSet
INFO: could not bind value '1' to parameter: 4
Apr 14, 2011 4:20:15 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 20000, SQLState: 07000
Apr 14, 2011 4:20:15 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: At least one parameter to the current statement is uninitialized.
Apr 14, 2011 4:20:15 PM org.hibernate.event.def.AbstractFlushingEventListener performExecutions
SEVERE: Could not synchronize database state with session
Throwable occurred: org.hibernate.exception.SQLGrammarException: could not insert collection: [com.deere.domain.ProductFamily.productAliveList#TESTPRODFAMID]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1058)
at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:26)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1009)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:356)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.deere.hibernate.ProductMaintain.main(ProductMaintain.java:48)
Caused by: java.sql.SQLException: At least one parameter to the current statement is uninitialized.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unknown Source)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1039)
... 10 more
Caused by: java.sql.SQLException: At least one parameter to the current statement is uninitialized.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
... 21 more
Caused by: ERROR 07000: At least one parameter to the current statement is uninitialized.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.execute.BaseActivation.throwIfMissingParms(Unknown Source)
at org.apache.derby.exe.acf81e0010x012fx53a1xf477x0000001f62d81.execute(Unknown Source)
at org.apache.derby.impl.sql.GenericActivationHolder.execute(Unknown Source)
at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown Source)
at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
... 15 more
org.hibernate.exception.SQLGrammarException: could not insert collection: [com.deere.domain.ProductFamily.productAliveList#TESTPRODFAMID]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1058)
at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:26)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1009)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:356)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.deere.hibernate.ProductMaintain.main(ProductMaintain.java:48)
Caused by: java.sql.SQLException: At least one parameter to the current statement is uninitialized.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unknown Source)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1039)
... 10 more
Caused by: java.sql.SQLException: At least one parameter to the current statement is uninitialized.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
... 21 more
Caused by: ERROR 07000: At least one parameter to the current statement is uninitialized.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.execute.BaseActivation.throwIfMissingParms(Unknown Source)
at org.apache.derby.exe.acf81e0010x012fx53a1xf477x0000001f62d81.execute(Unknown Source)
at org.apache.derby.impl.sql.GenericActivationHolder.execute(Unknown Source)
at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown Source)
at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
... 15 more
Apr 14, 2011 4:20:15 PM org.hibernate.util.JDBCExceptionReporter logWarnings
WARNING: SQL Warning: 10000, SQLState: 01J01
Apr 14, 2011 4:20:15 PM org.hibernate.util.JDBCExceptionReporter logWarnings
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

Could it possible be that in your mapping file you have:
<key-property name="aliveYr" type="integer" column="ALIVE_YR" />
That seems to be the parameter that is not getting set. Should it not be a short?

Sean
Prashant Langade
Ranch Hand

Joined: Jul 01, 2009
Posts: 71
Thanks a lot sean for pointing to the issue...

I did that change along with putting
cascade="save-update"
in


and it worked...

i really apreciate you ...
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377


Glad I could be of help.

Sean
 
wood burning stoves
 
subject: org.hibernate.PropertyAccessException: exception setting property value with CGLIB