Thom,
Quote:
Often when I reattach these dirty objects using Session.update(), I get Hibernate exceptions saying that a row couldn't be found. In most cases it seems like a delete is attempted that can't be found.
This makes me think that this doesnt happen frequently. Do you know an full usage scenario that causes this?
The purpose of update is to both reattach an object to a session and more specifically to tell Hibernate to persist this objects latest state. Other methods such as lock() reattach but tell hibernate to make the state of the object match what is in the db and not the other way around.
Anyway, you should check to verify that these items you are calling update on have primary keys according to your id generation strategy. For example, if you're updating and you let hibernate manage ids, then your object should have one. IF, you are just calling update on a bunch of objects and some of them may be transient in the sense that they've never been persisted, then switch over to using "saveOrUpdate". This method with the aid of your unsaved value strategy will update persisted objects or persist transient objects.
Now, if you're are sure these objects should already be in the db and when you go to reattach "update" and you're being told they dont exist, then you might be having an issue with cascading deletes. Meaning, some associated object is getting deleted and its taking this one down with it.
Just some ideas....
Sorry for the lack of clarity or cohesion to the response.
Joe