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: index values not get saved for List if inverse = true
PostPosted: Tue Jun 21, 2005 1:49 am 
Newbie

Joined: Tue Jun 21, 2005 1:03 am
Posts: 5
I have class "X" which contain List of "Y" objects
e.g

class X
{
List listOfY;
Sting name;
int id;
}

class Y{
String name;
int id;
int StartMonth;
int EndMonth;
int order;
X parentX;
}


and hibernate mapping like this
<class name ="X" table="TIME_X">
..........
......
....
<list name="listOfY" cascade="all" lazy="false" inverse="true" >
<key column="X_ID" />
<list-index column="Y_ORDER" base= "1"/>
<one-to-many class="Y"/>
</list>
.....
......
</class>

<class name = "Y" table ="TIME_Y">
-----
---
<many-to-one
name="parentX"
column="X_ID"
class="X"
/>
---
-----
</class>


I want to use list. Because I want hibernate to manipulate order. But we also have a bi-directional relationship between Class X and Class Y with inverse=true on indexed collection side. and also don’t want to map Y_ORDER column with order property of class Y.

with inverse = false, Hibernate is saving all the index values properly.

but for inverse = true
1) if there is mapping for Y_ORDER column with order property.
and order is not set then Hibernate saves "0" for Y_Order column

2) If there is no mapping for Y_ORDER with Order property

Hibernate inserts Null values for Y_ORDER column


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 5:12 am 
Newbie

Joined: Fri Oct 07, 2005 6:36 am
Posts: 7
Does anybody have a solution to this problem? I'm facing the same thing...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 5:35 am 
Newbie

Joined: Fri Oct 07, 2005 6:36 am
Posts: 7
Alright, the workaround is here:

http://forum.hibernate.org/viewtopic.ph ... ndex+saved


Top
 Profile  
 
 Post subject: Re: index values not get saved for List if inverse = true
PostPosted: Sun Jan 22, 2006 9:23 pm 
Newbie

Joined: Thu Oct 14, 2004 2:48 pm
Posts: 4
This really seems to be a bug.
Hibernate reference documentation recomends inverse="true" on bags and lists for better performance :

"19.5.3. Bags and lists are the most efficient inverse collections
...there is a particular case in which bags (and also lists) are much more performant
than sets. For a collection with inverse="true" (the standard bidirectional one-to-many relationship
idiom, for example) we can add elements to a bag or list without needing to initialize (fetch) the bag elements!"

I have tested this sceneraio with versions from 3.0.5 to 3.1.1.
So far, a one-to-many list is not able to save the index value when inverse="true"


Top
 Profile  
 
 Post subject: this is not a bug, please refer to the FAQ
PostPosted: Mon Jan 23, 2006 1:00 am 
Newbie

Joined: Mon Aug 09, 2004 7:29 am
Posts: 10
Location: India
http://hibernate.org/116.html#A12


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 23, 2006 1:01 am 
Newbie

Joined: Mon Aug 09, 2004 7:29 am
Posts: 10
Location: India
Please refer to this
http://opensource2.atlassian.com/projec ... owse/HB-79
http://hibernate.org/116.html#A12


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.