-->
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.  [ 1 post ] 
Author Message
 Post subject: Mapping Issue ?
PostPosted: Tue Aug 31, 2010 2:13 pm 
Newbie

Joined: Thu Nov 12, 2009 4:32 pm
Posts: 16
I have 2 tables, table A (parent) & table B(child) , table A to table B is One-To-Many relationships

here is my mappings

<class name="ObjectA" table="Table A">
<id name="id" column="id">
<generator class="sequence">
<param name="sequence">parent_id_s</param>
</generator>
</id>
<property name="userId" column="user_id"></property>
<property name="name" column="name"></property>
<set name="ObjectB" cascade="all">
<key column="id"></key>
<one-to-many class="Object B"/>
</set>

</class>

<class name="Object B" table="Table B">
<id name="addressId" column="address_id">
<generator class="sequence">
<param name="sequence">child_id_s</param>
</generator>
</id>
<property name="id" column="id"></property>
<property name="address" column="address"></property>
</class>

so id column of Table A is PK and id column of Table B is the FK of the same. As i said its 1 to Many relationships, One User(Object A/TableA) will have more than one Address Information(Object B/Table B), I tried to insert a new User record with One Address , It created a record in Table A and one record in Table B, Now i am trying to update User Info with another Address, in this Scenario it got updated the Table A and created another record in Table B which is fine, But its removing the value of the id field(FK) of the Previous Address Record. is there anything wrong with the Mapping above ?

any help would be much appreciated.

regards
DP


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.