update() vs saveOrUpdate()

Difference between update() and saveOrUpdate()

In hibernate update() method will perform updation on a record in database table if the specified record is existed otherwise it will rise an Exception.

public void update(Object obj)throws HibernateException

Where as saveOrUpdate(-) method will insert the specified record in database table if the specified record is not existed. If the specified record is existed in database table then it will update the record.

public void saveOrUpdate(Object obj)throws HibernateException
update() vs saveOrUpdate()


Scroll to top