-->
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: Confusion regarding Usage of Hibernate collection type List
PostPosted: Mon May 21, 2007 5:18 am 
Newbie

Joined: Mon May 21, 2007 4:59 am
Posts: 1
Hi,

Iam a newbie. I have some confusion regarding usage of index column
in List.
I have gone through the reference documentation, in that I see below
two differnt usages of List index column

Section 7.4 - Bidirectional association
------------------------------------------
In this section in the Person, Address example. I see that in Address
the list-index column = "peopleIdx".
But I don't see any such column in the create table statment for
Address.

Section 23.3 Customer/Oder/Product
------------------------------------------
Here in the mapping for Order class, I see the value of
list-index column ="line_number" and in the table definition of
line_items I see a column for line_number. But at the same time
there is no mention of line_number in the class diagram

So in view of above two examples, I need clarification on below

(1) What is the significance of list-index column ?
what does it means
(2) In case of Section-7.4 why list-index column value ("peopleIdx")
maps to a column that doesnot exist any where ?
How it works fine ?
(3) In case of Section.23.3, I see a column for the line_number , Why ?

(4) Can any one please give me a good example that clearly explains
usage of list and its properties ? The ones in the reference are
confusing :-(.

Iam confused when I should go by example given in Section-7.4
and when I should go by example given in Section-23.3.
Can any one please clarify with a clear and simple examples

Thanks and regards
Swayam


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 28, 2007 12:04 pm 
Newbie

Joined: Fri Sep 09, 2005 4:21 am
Posts: 5
Great question,

I have exactly the same confusion when i read the documents. And i am still trying to use list-index structure.

If someone could give a simple example (including database, hibernate mappings and java classes) it would really be great!!


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 29, 2007 4:08 am 
Senior
Senior

Joined: Thu May 17, 2007 2:31 am
Posts: 194
Location: Sri Lanka
Hi

All collection mappings, except those with set and bag semantics, need an index column in the collection table - a column that maps to an array index, or List index, or Map key. The index of a Map may be of any basic type, mapped with <map-key>, it may be an entity reference mapped with <map-key-many-to-many>, or it may be a composite type, mapped with <composite-map-key>. The index of an array or list is always of type integer and is mapped using the <list-index> element. The mapped column contains sequential integers (numbered from zero, by default).

extracts from 6.2.3. Indexed collections

So that means you don't nessasary to set list-index to a field in parent table. But you must mention a column which exist or which is in your query. In this section in the Person, Address example actually it doesn't work. trying to access list object (people) in address collection. it will give sqlgrammerexception. In this section in the Person, Address example it will return Addresslist . but error in accessing people List.


Amila

(Don't forget to rate if helps)


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.