These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: PropertyAccessException
PostPosted: Wed Nov 24, 2004 5:41 pm 
Beginner
Beginner

Joined: Thu Oct 14, 2004 10:53 pm
Posts: 45
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]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 6:33 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
All associations must be of type List/Set, custom implementations don't work.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 6:57 pm 
Beginner
Beginner

Joined: Thu Oct 14, 2004 10:53 pm
Posts: 45
[quote="michael"]All associations must be of type List/Set, custom implementations don't work.[/quote]

Yeah thanks for that.

Basically instead of the following

public class ORUMessage {
private PatientCollection patientCollection;

public PatientCollection getPatientCollection() {return patientCollection;}
public void setPatientCollection setPatientCollection(PatientCollection patientCollection) { this.patientCollection = patientCollection; }

}

I changed the type to List, like so

public class ORUMessage {
private List patientCollection

public List patientCollection getPatientCollection() { return patientCollection; }
public void setPatientCollection(List patientColelction patientCollection) {
this.patientCollection = patientCollection;

}

Now it seems that I have to lose the PatientCollection class.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.