Saturday, 5 September 2015

Difference between save, persist and saveOrUpdate methods in Hibernate?

After get vs load, this is another Hibernate Interview question which appears quite often. All three methods i.e. save()saveOrUpdate() and persist() is used to save objects into database, but has subtle differences e.g. save() can only INSERT records but saveOrUpdate() can eitheINSERT or UPDATE records. Also, return type of save() is a Serializable object, while return type of persist() method is void. You can also check save vs persist vs saveOrUpdate for complete differences between them in hibernate.

No comments:

Post a Comment