-->
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.  [ 4 posts ] 
Author Message
 Post subject: many-to-many List and index's
PostPosted: Fri Oct 03, 2003 3:19 am 
Beginner
Beginner

Joined: Mon Sep 15, 2003 6:55 pm
Posts: 29
I have a List of many-to-many items (cascade="all"). I can load, add and remove items from the list just fine. However, when I save the list and look in the database, the column mapped to the index is zero for all of the elements in the List. I've tried doing a session.save() on the listitem immediately after the element is added to the list, but it doesn't change anything. Am I doing something wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 03, 2003 3:27 am 
Beginner
Beginner

Joined: Mon Sep 15, 2003 6:55 pm
Posts: 29
Ok, I missed that an extra table had shown up, and the actual index was in that table. But it seems like a waste of space to have the index column in two places, when it's not used in the second place?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 03, 2003 3:28 am 
Beginner
Beginner

Joined: Mon Sep 15, 2003 6:55 pm
Posts: 29
To clarify, the index column is in both the table that bridges the collection and the collection elements, and in the table of the data for the collection element.


Top
 Profile  
 
 Post subject: help for you
PostPosted: Fri Oct 03, 2003 3:50 pm 
Beginner
Beginner

Joined: Thu Sep 04, 2003 2:50 pm
Posts: 45
Location: US: New York NY
Say you have
CREATE TABLE list {
list_id NUMERIC(12) NOT NULL
}
CREATE TABLE ad {
ad_id NUMERIC(12) NOT NULL
}
CREATE TABLE list_ads (
list_id NUMERIC(12) NOT NULL,
ad_id NUMERIC(12) NOT NULL,
sort_order INTEGER NULL
);
Then your mapping for your list would look something like this.

<list name="ad" table="list_ads" lazy="true" cascade="none">
<key column="list_id"></key>
<index column="sort_order"/>
<many-to-many class="com.example.Ad" column="ad_id" />
</list>


hope that helps


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