-->
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.  [ 3 posts ] 
Author Message
 Post subject: Session bean to Hibernate Tactio -> StaleObjectStateError
PostPosted: Sat Oct 04, 2003 4:44 pm 
Beginner
Beginner

Joined: Wed Sep 17, 2003 10:25 am
Posts: 36
I thouth I had this down but now I am seeing this error again so wanted to clearify that I understand this correctly. So any clarificaitons are appreciated.

This is what we are doing. I have an object lets say its called House. This object has a many to one relationship another object called Father :).
This relationship is bi-directional. The id for Father is auto-generated using GUID. I am calling a DAO object from a session bean.

Now, when I want to update Father, I am sending the update to a call to update House in the following way:

updateHouse(House h){

if(h.getFather()!=null){
//we have a father
if(h.getFather().getFatherId()!=null){
//this father is being updated
session.update(h.getFather());
}else{
//this father is being created for the House
session.save(h.getFather();
}
}

//The house has other properties that could also be updated
session.update(h);
}

Now when I run this code, I get a StaleObjectStateError on the Father object telling me the following:


Problem updating House: my.package.House@2c14f9[houseId=1] and the Exception Msg is:
my.package.util.DataAccessException: Problem hibernating....net.sf.hibernate.StaleObjectStateException: Row
was updated or deleted by another transaction (or unsaved-value mapping was incorrect) for my.package.Father instance with identifier: 402880e5f805977600f807d5f42b0004

The cascade on the relationship between House and Father is set to false. So when I call update on House, it should not cascade to Father. Not sure what's going on here but if anyone has seen this before and can point it out to me I would really appreciate it.

Thanks....


Top
 Profile  
 
 Post subject: anyone out there?
PostPosted: Sun Oct 05, 2003 3:59 pm 
Beginner
Beginner

Joined: Wed Sep 17, 2003 10:25 am
Posts: 36
Any help on this would be greatly appreciated. I am still stuck on this stale object error.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 06, 2003 2:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is a FAQ.

Please

(a) read the Parent / Child Relationship doco to understand how to use unsaved-value
(b) learn about saveOrUpdate()


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