-->
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.  [ 2 posts ] 
Author Message
 Post subject: ClassCastException with order-by and SortedSet
PostPosted: Wed Dec 17, 2003 2:09 pm 
Newbie

Joined: Wed Dec 17, 2003 1:57 pm
Posts: 4
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 ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2003 5:40 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Disable reflection optimizer or upgrade to 2.1. This gives more information about the error.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.