, session.saveOrUpdate, and session.persist



Share on Google+Share on Google+

samar , session.saveOrUpdate, and session.persist
1 Answer(s)      6 years and 7 months ago
Posted in : Hibernate Interview Questions

Difference between , session.saveOrUpdate() and session.persist()?

View Answers

March 7, 2011 at 4:58 PM

Hi Samar, : Save does an insert and will fail if the primary key is already persistent. 

session.saveOrUpdate() : saveOrUpdate does a select first to determine if it needs to do an insert or an update. 
Insert data if primary key not exist otherwise update data. 

session.persist() : Does the same like 
But return Serializable object but session.persist() return void.  returns the generated identifier (Serializable object) and session.persist() doesn't.


Related Tutorials/Questions & Answers: , session.saveOrUpdate, and session.persist , session.saveOrUpdate, and session.persist  Difference between , session.saveOrUpdate() and session.persist
Difference between , session.saveOrUpdate() and session.persist() in Hibernate
Difference between , session.saveOrUpdate() and session.persist...() , session.saveOrUpdate() and session.persist()in Hibernate? data. session.persist() : Does the same like But
Hibernate : Session Save
In this section we will discuss how works in Hibernate
Hibernate save Example - Rose India Hibernate 4 tutorials
saved the object using the method. Here in this section we..."); emp.setEmpAddress("Delhi - India");; tr.commit... the  to save the data. Here is the code of the model class
update count from session - Hibernate
update count from session  I need to get the count of how many rows got updated by session.saveOrUpdate(). How would I get this? Thanks, mpr
ramanjaneyulu  where is the SQL statement in this example? i mean when we call method it is inserting data into database. where it executes the insert statement. how can i see the insert statement in the code
Hibernate code - Hibernate
Hibernate code  can you show the insert example of Hibernate other than;  Hi I am sending a link where u can find lots of example related to hibernate...
Dirty Checking In Hibernate Example
then the Hibernate will save the object in database if and other methods... will save the object in database if and other methods are callled
); s2.getCourses().add(c2);;
Hibernate session.refresh() method
. session.refresh() reload all the data. No nned again to select call.
How to insert data from textfields into database using hibernate?
(IdCantitateTextField); produs.setUnitMas(UnitMasTextField);
could not execute native bulk manipulation query
"); } int row = query.executeUpdate(); //session.saveOrUpdate(query
Could not parse configuration: hibernate.cfg.xml
("kamlesh"); session.persist(e1); //persisting the object
Java - Hibernate
("Kumar"); contact.setEmail("[email protected]");"); contact.setEmail("[email protected]");; tr.commit
hibernate code - Hibernate
"); contact.setEmail("[email protected]");
java(Hibernate) - Hibernate
); System.out.println("user.setPhoneNumbers(s)"); //To Insert record throw {; System.out.println(""); tx.commit..."); user.setPhoneNo("9810254612");;
Struts2.2.1 and hibernate integration application
(); session.beginTransaction();
Hibernate Basic Example not working
");; System.out.println("Done"); }catch(Exception e
hibernate firstExample not inserting data - Hibernate
");; System.out.println("After Save"); } catch..."); contact.setEmail("[email protected]");
Reagrsding Hibernate joins - Hibernate
;); con.setState("bihar");;; tr.commit(); System.out.println("Done"
();; serealNo = (int)staffing.getSlNo...();; System.out.println("got sl no in registor Dao
Hibernate persist Method
); session.persist(employee); System.out.println("Data has been inserted to the table
Hibernate Load Example
");; tr.commit(); System.out.println("Successfully inserted..., sets the values and finally calls the  to save... to use Hibernate's method to save the data in our example
Problem in running first hibernate program.... - Hibernate
");; System.out.println("Done"); }catch(Exception...); tx = session.beginTransaction();
Hibernate 5 native query example
("000001"); emp1.setEmpAddress("Delhi - India");"); emp2.setEmpMobileNos("000002"); emp2.setEmpAddress("Delhi - India");
Hibernate saveOrUpdate Method
); session.saveOrUpdate(person); System.out.println("Successfully updated"
Hibernate save or update method example
Delhi, India"); session.saveOrUpdate(emp); tr.commit
hibernate pojo setter method problem
); Transaction tx=session.beginTransaction();
in connectivity - Hibernate
"); contact.setEmail("[email protected]");
Hibernate Architecture
an object to a method, Hibernate reads the state