-->
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.  [ 5 posts ] 
Author Message
 Post subject: Fore hibernate to use LinkedHashSets
PostPosted: Fri Aug 04, 2006 4:05 pm 
Newbie

Joined: Fri Aug 04, 2006 2:53 pm
Posts: 2
Hi,
Is there any way I can fore hibernate to use LinkedHashSets instead of its PersistentSet?

I have a menber atrribute and I would like use it as a LinkedHashSet like in the code below

private LinkedHashSet<AdFolder> subFolders = new LinkedHashSet<AdFolder>();

I cannot use Set because I use XFire to return the bean to the client and it transforms Sets int o HashSets and the order is lost that way.

Thanks


Hibernate version:
3.1.3
java 1.5

Mapping documents:


<set name="subFolders" inverse="true" lazy="false"
order-by="name asc">
<key column="parentAdFolderId" />
<one-to-many
class="br.com.carber.AdFolder" />
</set>



Code between sessionFactory.openSession() and session.close():
I´m using spring

Full stack trace of any exception that occurs:

Name and version of the database you are using:
Oracle 10G


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 4:14 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
page 216 of hibernate in action

"Under the covers, Hibernate uses a LinkedHashSet to implement ordered sets"

so you could just cast it. But if you want it generated by hbm2java just do

Code:
<set
       ...
       
    >
    <meta attribute="property-type">java.util.LinkedHashSet</meta>
...

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject: What is happening then?
PostPosted: Fri Aug 04, 2006 4:19 pm 
Newbie

Joined: Fri Aug 04, 2006 2:53 pm
Posts: 2
Well in my case it seems it is not. I receive a IllegalArgumentException saying telling me I cannot assign a PersistantSet in a LinkHashSet

2006-08-04 17:17:53,476 ERROR [http-8080-2] hibernate.property.BasicPropertyAccessor$BasicSetter (BasicPropertyAccessor.java:94) - IllegalArgumentException in class: br.com.carber.AdFolder, setter method of property: subFolders
2006-08-04 17:17:53,476 ERROR [http-8080-2] hibernate.property.BasicPropertyAccessor$BasicSetter (BasicPropertyAccessor.java:98) - expected type: java.util.LinkedHashSet, actual value: org.hibernate.collection.PersistentSet
2006-08-04 17:17:53,476 INFO [http-8080-2] xfire.handler.DefaultFaultHandler (DefaultFaultHandler.java:34) - Fault occurred!
o


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 06, 2006 11:02 am 
Newbie

Joined: Tue Oct 11, 2005 10:57 am
Posts: 13
The HQL mechanism will consider the attribute="property-type" when executing HQL statements to? Or this configuration works only when I use get methods that returns a collection (Set, List, ...).

Thanks in advance.


Last edited by reolca on Wed Dec 06, 2006 11:04 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 06, 2006 11:03 am 
Newbie

Joined: Tue Oct 11, 2005 10:57 am
Posts: 13
The HQL mechanism will consider the attribute="property-type" when executing HQL statements to? Or this configuration works only when I use get methods that returns a collection (Set, List, ...).

Thanks in advance.


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