I'm having troubles using the order-by attribute of the <set> tag
with Hibernate 2 and JDK 1.4
I've got a class (referred to as MyClassDTO in the mapping below) that contains a collection defined as a SortedSet
MyClassDTO contains the attributes
String objId
String name
SortedSet approvals (initialized to a new TreeSet() )
The objects placed in the collection are ApprovalDTO objects which implement the Comparable interface
The mapping for this collection uses the <set> tag
I can populate the object and collection just fine without the order-by attribute, using just the sort=natural attribute
However, as soon as I add the "order-by" attribute to the mapping I get a ClassCast Exception
Here's the mapping:
<class name="MyClassDTO"
table="MYTABLE"
mutable="false">
<id name="objId" column="tableKey" type="string" unsaved-value="null">
<generator class="assigned"/>
</id>
<property name="name" column="_name" type="string"/>
<set name="approvals"
table="APPROVALS"
cascade="none"
order-by="type_code, class_code">
<key column="target_code"/>
<one-to-many class="ApprovalDTO"/>
</set>
</class>
Here's the trace:
Caused by: net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB setter of com.hp.mss.bussvc.SupplierDisciplinesDTO.?
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:163)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1973)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:196)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:573)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:392)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1901)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1769)
at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1700)
at com.hp.mss.core.PersistenceManager.load(PersistenceManager.java:140)
... 41 more
Caused by: java.lang.ClassCastException
at com.hp.mss.bussvc.SupplierDisciplinesDTOMetaClass10.setPropertyValues()
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:158)
What am I doing wrong ?
|