I'm having trouble with this exception. I have a colection field called patientCollection. The field is of type PatientCollection which extends ArrayList.
The collection mapping in my mapping file is below (called ORUMessage.hbm.xml), which has a uni-directional ref to Patient.hbm.xml.
<bag name="patientCollection" cascade="all">
<key column="patientFK"/>
<one-to-many class="com.orchestral.cdr.element.Patient"/>
</bag>
When reading the error message, I've set hibernate.cglib.use_reflection_optimizer=false in my hibernate.cfg.xml like so:
<property name="hibernate.cglib.use_reflection_optimizer">false</property>
but it didn't really help me get around the original error. The stack trace is below.
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.orchestral.cdr.message.ORUMessage.setPatientCollection
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:213)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:924)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:779)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
at com.orchestral.cdr.CDRDBBaseImpl.persist(CDRDBBaseImpl.java:287)
at com.orchestral.cdr.element.PersistHL7MessageTest.testPersistORUMessage(PersistHL7MessageTest.java:77)
at java.lang.reflect.Method.invoke(Native Method)
at junit.framework.TestCase.runTest(TestCase.java:166)
at junit.framework.TestCase.runBare(TestCase.java:140)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:131)
at junit.framework.TestSuite.runTest(TestSuite.java:173)
at junit.framework.TestSuite.run(TestSuite.java:168)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: net.sf.cglib.beans.BulkBeanException: net.sf.hibernate.collection.Bag
at com.orchestral.cdr.message.ORUMessage$$BulkBeanByCGLIB$$14137826.setPropertyValues(<generated>)
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:208)
... 18 more
Caused by: java.lang.ClassCastException: net.sf.hibernate.collection.Bag
... 20 more
This is the code in my ORUMessage.setPatientCollection
public void setPatientCollection(PatientCollection patientCollection) {
this.patientCollection = patientCollection;
}
It appears that Hibernate doesn't like the custom extended PatientCollection type. Can anyone help?
[b]Hibernate version:2.1.6[/b]
[b]Mapping documents:
hibernate.cfg.xml
....
<property name="hibernate.cglib.use_reflection_optimizer">false</property>
....
ORUMessage.hbm.xml
...
<bag name="patientCollection" cascade="all">
<key column="patientFK"/>
<one-to-many class="com.orchestral.cdr.element.Patient"/>
</bag>
...
[/b]
[b]Code between sessionFactory.openSession() and session.close():[/b]
[b]Full stack trace of any exception that occurs:
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.orchestral.cdr.message.ORUMessage.setPatientCollection
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:213)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:924)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:779)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
at com.orchestral.cdr.CDRDBBaseImpl.persist(CDRDBBaseImpl.java:287)
at com.orchestral.cdr.element.PersistHL7MessageTest.testPersistORUMessage(PersistHL7MessageTest.java:77)
at java.lang.reflect.Method.invoke(Native Method)
at junit.framework.TestCase.runTest(TestCase.java:166)
at junit.framework.TestCase.runBare(TestCase.java:140)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:131)
at junit.framework.TestSuite.runTest(TestSuite.java:173)
at junit.framework.TestSuite.run(TestSuite.java:168)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: net.sf.cglib.beans.BulkBeanException: net.sf.hibernate.collection.Bag
at com.orchestral.cdr.message.ORUMessage$$BulkBeanByCGLIB$$14137826.setPropertyValues(<generated>)
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:208)
... 18 more
Caused by: java.lang.ClassCastException: net.sf.hibernate.collection.Bag
... 20 more
[/b]
[b]Name and version of the database you are using:[/b]
[b]The generated SQL (show_sql=true):[/b]
[b]Debug level Hibernate log excerpt:
[DEBUG] (cdr.element.PersistHL7MessageTest ) - Creating a test ORUMessage object
[DEBUG] (cdr.element.PersistHL7MessageTest ) - Persisting the ORUMessage object
[DEBUG] (hibernate.impl.SessionImpl ) - opened session
[DEBUG] (bernate.transaction.JDBCTransaction) - begin
[DEBUG] (ion.DriverManagerConnectionProvider) - total checked-out connections: 0
[DEBUG] (ion.DriverManagerConnectionProvider) - using pooled JDBC connection, pool size: 0
[DEBUG] (bernate.transaction.JDBCTransaction) - current autocommit status:false
[DEBUG] (ion.DriverManagerConnectionProvider) - total checked-out connections: 1
[DEBUG] (ion.DriverManagerConnectionProvider) - opening new JDBC connection
[DEBUG] (ion.DriverManagerConnectionProvider) - created connection to: jdbc:inetdae:CONTRACT1:1433?database=test, Isolation Level: 2
[DEBUG] (ion.DriverManagerConnectionProvider) - returning connection to pool, pool size: 1
[DEBUG] (hibernate.id.TableHiLoGenerator ) - new hi value: 1528
[DEBUG] (hibernate.impl.SessionImpl ) - generated identifier: 50069505
[DEBUG] (hibernate.impl.SessionImpl ) - saving [com.orchestral.cdr.message.ORUMessage#50069505]
[DEBUG] (hibernate.engine.Cascades ) - processing cascades for: com.orchestral.cdr.message.ORUMessage
[DEBUG] (hibernate.engine.Cascades ) - done processing cascades for: com.orchestral.cdr.message.ORUMessage
[DEBUG] (hibernate.impl.WrapVisitor ) - Wrapped collection in role: com.orchestral.cdr.message.ORUMessage.patientCollection
[DEBUG] (hibernate.impl.SessionImpl ) - running Session.finalize()
[ WARN] (hibernate.impl.SessionImpl ) - afterTransactionCompletion() was never called
[ WARN] (hibernate.impl.SessionImpl ) - unclosed connection
[/b]
|