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.
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....
|