-->
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.  [ 8 posts ] 
Author Message
 Post subject: Middlegen: How to change collections from Set to List ?
PostPosted: Sun Mar 27, 2005 1:46 pm 
Regular
Regular

Joined: Fri Mar 04, 2005 1:33 pm
Posts: 65
Location: U.K.
Hi

I am using Hibernate 2.1 and Midllegen 2.1. The Middlegen plugin for Hibernate generates all the POJOs. Some of theses POJOs have child collections defined as 'Set'. This collections to make it as Set is a default behavior of Middlegen tool. I was wondering if any of you have changed to a 'List' ? I think the 'List' will give a better way for clients to sort it. At present, we need to change it to the List explicitly.

Thanks
Ron


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 27, 2005 5:05 pm 
Senior
Senior

Joined: Fri May 14, 2004 9:37 am
Posts: 122
Location: Cologne, Germany
Hi,

take a look at the hibernate.vm inside the Hibernate-plugin.jar There you might change the render behaviour from Set to List or even List<E>.

_________________
regards

Olaf

vote if it helped


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 28, 2005 9:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
True - you can change the set to List but you need to workout the index .
A quick hack is easy but doing it correctly if much more difficult. If you do a good job of it I would be interested in the patch so I can consider commiting it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 29, 2005 3:16 am 
Senior
Senior

Joined: Fri May 14, 2004 9:37 am
Posts: 122
Location: Cologne, Germany
Hi David

true I also thought it was quite easy to change the behaviour of the render and thx for the response in the other thread.
The problem of the Index isn't quite clear to me. I know it'll be nice to have a sorted List instead of a unsorted one, but aren't the Sets also unsorted ?

_________________
regards

Olaf

vote if it helped


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 30, 2005 11:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
See collections
http://www.hibernate.org/hib_docs/reference/en/html/collections.html

The list uses an index column to determine the position of the object.
So once issue is selecting the appropriate index column.
Second issue that the index column causes issues in dealing with bi-directional mappings.

Sets don't have either of these issues thus I left it as a future exercise (to the reader).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 31, 2005 12:52 am 
Senior
Senior

Joined: Fri May 14, 2004 9:37 am
Posts: 122
Location: Cologne, Germany
Oh ok the index tags haven't thought about them. Perhaps I might be able to do a spike next week, but not foresure short in time at the moment.

_________________
regards

Olaf

vote if it helped


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 28, 2005 1:25 pm 
Beginner
Beginner

Joined: Thu Apr 28, 2005 6:16 am
Posts: 20
Quote:
True - you can change the set to List but you need to workout the index .
A quick hack is easy but doing it correctly if much more difficult. If you do a good job of it I would be interested in the patch so I can consider commiting it.


Ah, so there's no way of specifying the collection to use for relations in middlegen? This is exactly what I've been reading around to see how to do.

It also appears that mergefiles are not going to help here, right? Is there a way to override generated middlegen code with hand "corrected" hbm.xml tags?

cheers
merlyn


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 30, 2005 8:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You could post process the HBM to modify the output. Having said that, its very easy to change the Velocity script to get the List instead of the Set which might satisfy your requirements. Its much more difficult to do it correctly for all the variations that can occur - hence why I have not done it.


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