-->
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: Mapping java.util.List
PostPosted: Wed Nov 28, 2007 6:03 pm 
Newbie

Joined: Wed Nov 28, 2007 5:53 pm
Posts: 3
Hello All,

I am relatively new to Hibernate and hence this question. I have a java class that contains elements of the type java.util.List.

public class Application extends DataObject {

private List investments = null;

public List getInvestments() {
return investments;
}

public void setInvestments(List investments) {
this.investments = investments;
}

}


I am creating the Hibernate mapping file. How do I map an attribute of the type java.util.List.

Any help will be highly appreciated. If you can point me to the right place in the documentation, that will be great too.

Regards,
Kunal


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 29, 2007 1:04 am 
Newbie

Joined: Tue Nov 27, 2007 3:17 am
Posts: 5
U can map a list using <bag> tag or <list> tag
if u use <bag> then the mapping would be like this in accordance to ur class
<bag name="investments">
<key column="column refering to application id"/>
<one-to-many class="ur_investment_class" />
</bag>

in the case of <list> tag u have to maintain an additional column holding the list index(i.e ur invetments insertion order) in ur DB as well as in ur class. Then the mapping will be
<list name="investemnts">
<key column="column refering to application id"/>
<index name="index_property_name" column="index_column" />
<one-to-many class="ur_investment_class" />
</list>

as per my knowledge this is the soultion.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 30, 2007 11:48 am 
Newbie

Joined: Wed Nov 28, 2007 5:53 pm
Posts: 3
Thanks for the response Pokuri.

I am trying out both the solutions.

Will select one.

Again, appreciate your response.


Kunal


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.