-->
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.  [ 2 posts ] 
Author Message
 Post subject: One to many mapping using List and index column
PostPosted: Thu Feb 07, 2008 11:32 am 
Newbie

Joined: Fri Apr 28, 2006 1:48 pm
Posts: 7
Hello,

I need to have a one to many relation between the PARENTS - CHILDS tables; and need
the parent the loaded childrens in an indexed collection, so I preserve the order by index.

The problem I have: When I persist the parent, it seems fine, excepting the fact that on the CHILDS
table I see an extra UPDATE that populates the index_col and the PARENT_ID and I don't like that.

I tried to have the mapping attribute inverse = "true" to avoid the problem, the update seems to
go away but the index_col column is left NULL. Any suggestions?


<class name="Parent" table="Parents">

<id name="ID" type="long" column="ID">
<generator class="sequence">
<param name="sequence">sq_id</param>
</generator>
</id>

<property name="field1" column="field1" type="string" length="64"/>

<list name="childrens" table="CHILDS" cascade="all" batch-size="100">
<key column="PARENT_ID" />
<index column="index_col"/>
<one-to-many class="myPackage.Children"/>
</list>
</class>


Thanks,
Valy Sivec


Top
 Profile  
 
 Post subject: Re: One to many mapping using List and index column
PostPosted: Thu Feb 07, 2008 7:35 pm 
Newbie

Joined: Thu Feb 07, 2008 6:42 pm
Posts: 4
can you post the database schema for the tables?


valysivec27 wrote:
Hello,

I need to have a one to many relation between the PARENTS - CHILDS tables; and need
the parent the loaded childrens in an indexed collection, so I preserve the order by index.

The problem I have: When I persist the parent, it seems fine, excepting the fact that on the CHILDS
table I see an extra UPDATE that populates the index_col and the PARENT_ID and I don't like that.

I tried to have the mapping attribute inverse = "true" to avoid the problem, the update seems to
go away but the index_col column is left NULL. Any suggestions?


<class name="Parent" table="Parents">

<id name="ID" type="long" column="ID">
<generator class="sequence">
<param name="sequence">sq_id</param>
</generator>
</id>

<property name="field1" column="field1" type="string" length="64"/>

<list name="childrens" table="CHILDS" cascade="all" batch-size="100">
<key column="PARENT_ID" />
<index column="index_col"/>
<one-to-many class="myPackage.Children"/>
</list>
</class>


Thanks,
Valy Sivec


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