in Technology by
What is Difference between save(), saveOrUpdate() and persist() in Hibernate Session?

1 Answer

0 votes
by
The Session interface in Hibernate provides a couple of methods to move an object from a new or transient state to a persistent state e.g. save(), saveOrUpdate(), and persist() are used to store an object into the database, but there are some significant differences between them. The Session.save() method does an INSERT to store the object into the database and it also returns the identifier generated by the database. On the other hand, saveOrUpdate() can be used to reattach a detached object in Hibernate Session i.e. it can do INSERT or UPDATE depending upon whether an object exists in the database or not.

Related questions

0 votes
    What is the difference between save() and persist() method in Hibernate?...
asked Feb 4, 2021 in Technology by JackTerrance
0 votes
    I have a problem with Hibernate. In Short: How to configure a ManyToMany association with Hibernate when the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 21, 2022 in Education by JackTerrance
0 votes
    Facing issue in session with the upgrade of my application to Spring 4.1.9 and Hibernate 4.3.11.. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    What is the difference between Hibernate and EJB 3? Do not you think EJB 3 is just a clone of Hibernate?...
asked Jun 5, 2021 in Technology by JackTerrance
0 votes
    What is the difference between the first and second level cache in Hibernate?...
asked Feb 4, 2021 in Technology by JackTerrance
0 votes
    Difference between get() vs load() method in Hibernate?...
asked Feb 4, 2021 in Technology by JackTerrance
0 votes
    What is the difference between HttpContext.Current.Items and HttpContext.Current.Session in ASP.NET?...
asked Apr 7, 2021 in Education by JackTerrance
0 votes
    What is the Difference between session and caching?...
asked Apr 7, 2021 in Education by JackTerrance
0 votes
    How To Persist Root Device Volume In Amazon Ec2 Instance ?...
asked Mar 12, 2021 in Technology by JackTerrance
0 votes
    Regarding the Castle Automatic Transaction Management Facility; I'm having some difficulties getting operations to ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    If you see jqGrid demo : http://www.trirand.com/blog/jqgrid/jqgrid.html Section : Advanced --> ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 11, 2022 in Education by JackTerrance
0 votes
    If you see jqGrid demo : http://www.trirand.com/blog/jqgrid/jqgrid.html Section : Advanced --> ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 10, 2022 in Education by JackTerrance
0 votes
    I am migrating my Java,Tomcat, Mysql server to AWS EC2. I have already attached EBS volume for storing MySql ... you guide. Thanks Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I am migrating my Java,Tomcat, Mysql server to AWS EC2. I have already attached EBS volume for storing MySql ... you guide. Thanks Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    What are the differences between stateful session bean and stateless session bean?...
asked Nov 7, 2020 in Technology by JackTerrance
...