aspose file tools*
The moose likes Object Relational Mapping and the fly likes Session update method in hibernate? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Session update method in hibernate?" Watch "Session update method in hibernate?" New topic
Author

Session update method in hibernate?

scott miles
Ranch Hand

Joined: Jun 16, 2011
Posts: 70
I am new to hibernate and going through hibernate tutorial. While going thru update method in session i found below statement at
http://docs.jboss.org/hibernate/annotations/3.5/api/org/hibernate/Session.html#update(java.lang.Object)

void update(Object object) Update the persistent instance with the identifier of the given detached instance. If there is a persistent instance with the same identifier, an exception is thrown. This operation cascades to associated instances if the association is mapped with cascade="save-update.

I have a question about statement If there is a persistent instance with the same identifier, an exception is thrown. I could not understand this statement. As per my understanding - persistent instance with the same identifier needs to be there in database to update the value Sure i am missing something here. Looking for that miss?

Statement2
"This operation cascades to associated instances if the association is mapped with cascade="save-update". I think whatever the associations are there in persistent instance , they will also be updated if the association is mapped with cascade="save-update. Right? like customerinfo has accountinfo. So if we make change in customerinfo and accountinfo both. Both the changes will be persisted.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session update method in hibernate?