0

What's the difference between saveOrUpdate and merge using hibernate and sessionFactory?

Sidaoui Majdi
  • 399
  • 7
  • 26

1 Answers1

0

Hibernate saveOrUpdate

  • results into insert or update queries based on the provided data. If the data is present in the database, update query is executed.

Hibernate merge

  • can be used to update existing values, however this method create a copy from the passed entity object and return it. The returned object is part of persistent context and tracked for any changes, passed object is not tracked. This is the major difference with merge() from all other methods used to save data
Neeraj Jain
  • 7,643
  • 6
  • 34
  • 62