Hibernate 2.1.x, calling save() on same object twice causes two INSERTS
Hibernate is not performing as I would expect. When I am saving for the second time, it generates a second insert statement (as opposed to an UPDATE for the 2nd call). It probably has something to do with the specifics of my situation. I am....
I really would like to do everything with the save() method, but it seems the solution (for now) lies in which API call I use.
Theoretically, there should only be one call, and hibernate should determine this for me. There are references to a method called saveOrUpdate(), but it should only be used when sharing objects across sessions.
- creating an object
- saving it within a session
- later, i try updating this same object handle within the same session (i.e. no re-retrieve)
I really would like to do everything with the save() method, but it seems the solution (for now) lies in which API call I use.
- save() seems geared towards new instances
- update() seems geared towards existing ones
Theoretically, there should only be one call, and hibernate should determine this for me. There are references to a method called saveOrUpdate(), but it should only be used when sharing objects across sessions.


0 Comments:
Post a Comment
<< Home