-->
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: many-to-one adds new row on update
PostPosted: Tue Jun 15, 2010 9:25 am 
Newbie

Joined: Tue Jan 05, 2010 2:33 pm
Posts: 15
I have a Class Employee which maps to a table employee.

I have another table called address which has its corresponding Address class.

Employee contains an object called Address :
Code:
class Employee{
private Address employeeAddress;
}

In my employee table I have a column called address_id which links to a row in the address table.

In my hibernate mapping file I have :
Code:
<many-to-one name="employeeAddress" class="com.dao.bean.Address"  unique="true" cascade="all" column="address_id"/>


When I add a new employee the new row is added to the address table and the address_id in the employee table matches the new row.

However when I update an employee it also creates a new row in the the address table and sets the address_id in the employee table to the new row. Fuctionaly it will still work but I cant have this table growing everytime there is an update.

Any ideas about what I am doing wrong ???

Thanks in advance

Spunog


Top
 Profile  
 
 Post subject: Re: many-to-one adds new row on update
PostPosted: Tue Jun 15, 2010 9:36 am 
Newbie

Joined: Tue Jan 05, 2010 2:33 pm
Posts: 15
I forgot to mention I am using MYSQL DB and hibernate 3


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.