Thursday, September 25, 2014

Difference between save and saveOrUpdate method hibernate

save
Save method stores an object into the database. It will Persist the given transient instance, first assigning a generated identifier. It returns the id of the entity created.
Whereas,
SaveOrUpdate()
Calls either save() or update() on the basis of identifier exists or not. e.g if identifier exists, save()will be called or else update() will be called.
There are many more like persist(), merge(), saveOrUpdateCopy(). Almost all are same giving slight different functionality and usability.

No comments:

Post a Comment