-->
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.  [ 7 posts ] 
Author Message
 Post subject: primary key with list
PostPosted: Tue May 03, 2005 4:40 pm 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
In the chapter 6, in the section Using a List, the author said: "The primary key consists of the ITEM_ID and POSITION columns".
This is an obligation? Can I use an Id as a primary key of List elements?
If I have a list in my java class, as "private List customers", must I use the <list> in the mapping files?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 03, 2005 5:13 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Uh, this is completely explained in the chapter you are reading. Maybe re-read.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 7:52 am 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
Ok, sorry, you're right. The name of the section is "Mapping collections of value types". I already understand that I should use id for entity types and not use for value types.

But, I don't understand the question about use of lists or sets yet. It's true that the association semantics of my collections is set, because the table structure doesn't support duplicates. But I want to use List object in my java code. In this case, what should I do? Use <set> in the mapping files and List in my java code? Can I do this? Or should I use <list> or <bag> in my mapping files?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 7:55 am 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
The use of <bag> when I need a List in java code is an obligation?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 8:18 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Why not read page 212 again.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 9:31 am 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
Thank you for attention.
You wrote that bag permits duplicated elements. I don't need this behavior. The only thing I need is to use List in java.
In all my cases, the real semantic is set (but the database table provide this). But in java code I need the List, because I will show the collections in JTable, that need a index for search the collection element.
So, the solution still be the use of the <bag> ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 10:08 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Why not?


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