-->
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: bug? XML Mapping with sort="natural"
PostPosted: Tue Mar 22, 2005 3:18 pm 
Regular
Regular

Joined: Tue Sep 28, 2004 6:34 pm
Posts: 50
When you have following mapping:

Code:
      <set
              name="products"
              lazy="false"
              table="category2product"
              sort="natural"
              node="products"
              embed-xml="true">
         <key column="categoryId"/>
         <many-to-many class="Product" column="productId" embed-xml="true" node="product" />
      </set>


and try when you try to fetch it as XML:
Code:
        Session dom4jSession = session.openSession(EntityMode.DOM4J);
        List results = dom4jSession.createQuery("from Category").list();

it you will get:
Code:
java.lang.ClassCastException: org.dom4j.tree.DefaultElement
   at java.util.TreeMap.compare(TreeMap.java:1085)
   at java.util.TreeMap.put(TreeMap.java:463)
   at java.util.TreeSet.add(TreeSet.java:209)
   at java.util.AbstractCollection.addAll(AbstractCollection.java:319)
   at java.util.TreeSet.addAll(TreeSet.java:255)
   at org.hibernate.collection.PersistentSet.endRead(PersistentSet.java:237)
   at org.hibernate.engine.CollectionLoadContext.endLoadingCollection(CollectionLoadContext.java:170)
   at org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:244)
   at org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:227)
   at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:458)
   at org.hibernate.loader.Loader.doQuery(Loader.java:406)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:203)
   at org.hibernate.loader.Loader.loadCollection(Loader.java:1344)
   at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:101)
   at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:484)
   at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
   at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1346)
   at org.hibernate.type.CollectionType.getCollection(CollectionType.java:439)
   at org.hibernate.type.CollectionType.resolve(CollectionType.java:296)
   at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:105)
   at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:452)
   at org.hibernate.loader.Loader.doQuery(Loader.java:406)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:203)
   at org.hibernate.loader.Loader.doList(Loader.java:1499)
   at org.hibernate.loader.Loader.list(Loader.java:1482)
   at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:365)
   at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:268)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:782)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)


When you do eliminate the sort="natural" it works fine.
It seams to me that there is some bug in either comparator for tree set, of for compare function for elements that are added to the set.

Lukasz


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 22, 2005 5:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
ooops, forgot to fill that in

fixed now in cvs


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 22, 2005 5:34 pm 
Regular
Regular

Joined: Tue Sep 28, 2004 6:34 pm
Posts: 50
thanks


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.