-->
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.  [ 6 posts ] 
Author Message
 Post subject: Why do we need list-index ??????????
PostPosted: Thu Nov 30, 2006 11:23 am 
Newbie

Joined: Thu Nov 30, 2006 11:08 am
Posts: 6
Location: Manchester, United Kingdom
OK so i have 3 tables...

PRODUCT_GROUP
PRODUCT_SUBTYPE

and the many to many table...

PRODUCT_GROUP_SUBTYPE

The last table initally had 2 columns just the ids of the GROUP and SUBTYPE tables. This seemed to work perfectly well if i wanted to use sets, but didn't work at all if i wanted to use lists, as a list requires a list-index or index. WHY???

We want to use lists in our code not sets, so to get around this problem I added another column to the PRODUCT_GROUP_SUBTYPE table called PRODUCT_GROUP_SUBTYPE_ID and it just has the values 1..n (i.e. first row it's 1, 2nd row it's 2, nth row it's n)

I set the list index to this column, and all of a sudden it works....Why do I need this column???

here's the mapping...

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="com.hidden.value.ProductGroupValue" table="product_group">
        <id name="productGroupId" column="PRODUCT_GROUP_ID" unsaved-value="0"/>
        <property name="description" column="DESCRIPTION"/>
        <property name="roleId" column="ROLE"/>
        <list name="productSubTypes" table="product_group_subtype">
            <key column="product_group_id"/>
            <list-index column="product_group_subtype_id"/>
            <many-to-many class="com.hidden.value.ProductSubTypeValue" column="product_subtype_id"/>
        </list>
    </class>
</hibernate-mapping>


It all works ok now, but just puzzled on why i should need to add the extra column??????

cheers

Andy.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 11:37 am 
Beginner
Beginner

Joined: Thu Aug 24, 2006 6:01 am
Posts: 49
Location: sophia-antipolis, France
did you read "understanding collection performance" in chapter 19.5 of the reference guide?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 11:49 am 
Newbie

Joined: Thu Nov 30, 2006 11:08 am
Posts: 6
Location: Manchester, United Kingdom
wykoff wrote:
did you read "understanding collection performance" in chapter 19.5 of the reference guide?


No need to be like that......I was only asking a simple question!!!!!!!!!

No I hadn't, I've just had a quick look and it seems to make sense. Although it is still pointless in my case as the group and subtype tables contain static data and won't be updated via hibernate, only read from.

Andy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 12:00 pm 
Regular
Regular

Joined: Wed Mar 23, 2005 8:43 am
Posts: 105
Location: Moscow, Russia
Because List implies ordering of its elements. 'list-index' or 'index' elements defines that order. If you don't need the order, you may use bag, which defines List with Bag semantic (no guarantee about order).

_________________
Best Regards


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 12:12 pm 
Newbie

Joined: Thu Nov 30, 2006 11:08 am
Posts: 6
Location: Manchester, United Kingdom
lester wrote:
Because List implies ordering of its elements. 'list-index' or 'index' elements defines that order. If you don't need the order, you may use bag, which defines List with Bag semantic (no guarantee about order).


Thank you!!! thats perfect!!!

Cheers

Andy

_________________
"because dressing like a pirate is cool"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 12:16 pm 
Beginner
Beginner

Joined: Thu Aug 24, 2006 6:01 am
Posts: 49
Location: sophia-antipolis, France
kaylanx wrote:
No need to be like that......I was only asking a simple question!!!!!!!!
Andy


Actually, I wasn't being snide! I simply didn't know if you had read it and it still didn't make sense or if you hadn't yet found that part of the reference.


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