Tutorialspoint examples

Learn java tutorial with examples for beginners online

What is the difference between session.save session.saveorupdate and session.persist in hibernate?



Serializable save(Object object) throws HibernateException
Serializable save(String entityName,
                  Object object)
                  throws HibernateException

Save method is used to store an object into the database. It insert an entry if the identifier doesn’t exist. It will throw error if the identifier already exist.


void update(Object object) throws HibernateException
void update(String entityName,
            Object object)
            throws HibernateException

Update method in the hibernate is used for updating the object using identifier. It will throw an exception if the identifier is missing or doesn’t exist.


void saveOrUpdate(Object object)throws HibernateException
void saveOrUpdate(String entityName,
                  Object object)
                  throws HibernateException

The saveOrUpdate method calls save() or update() method based on the operation. If the identifier exists, it will call update method else the save method will be called.

Download tutorialspointexamples Android App
Copyright © 2018 Tutorialspoint examples DMCA.com Protection Status