, session.saveOrUpdate, and session.persist



Share on Google+Share on Google+

samar , session.saveOrUpdate, and session.persist
1 Answer(s)      6 years and 3 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
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...
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
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
could not execute native bulk manipulation query
"); } int row = query.executeUpdate(); //session.saveOrUpdate(query
); s2.getCourses().add(c2);;
How to insert data from textfields into database using hibernate?
(IdCantitateTextField); produs.setUnitMas(UnitMasTextField);
Hibernate session.refresh() method
. session.refresh() reload all the data. No nned again to select call.
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 Basic Example not working
");; System.out.println("Done"); }catch(Exception e
Struts2.2.1 and hibernate integration application
(); session.beginTransaction();
java(Hibernate) - Hibernate
); System.out.println("user.setPhoneNumbers(s)"); //To Insert record throw {; System.out.println(""); tx.commit..."); user.setPhoneNo("9810254612");;
hibernate code - Hibernate
"); contact.setEmail("[email protected]");
();; serealNo = (int)staffing.getSlNo...();; System.out.println("got sl no in registor Dao
Reagrsding Hibernate joins - Hibernate
;); con.setState("bihar");;; tr.commit(); System.out.println("Done"
hibernate firstExample not inserting data - Hibernate
");; System.out.println("After Save"); } catch..."); contact.setEmail("[email protected]");
Hibernate persist Method
); session.persist(employee); System.out.println("Data has been inserted to the table
Hibernate save or update method example
Delhi, India"); session.saveOrUpdate(emp); tr.commit
Hibernate saveOrUpdate Method
); session.saveOrUpdate(person); System.out.println("Successfully updated"
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 Many One One Mapping
* Student("Syam", address);;; Student syam = new * Student("Syam", address);;; * * transaction.commit(); */ And comment the following
Hibernate Transaction
;);; tx.commit(); System.out.println("Done"
in connectivity - Hibernate
"); contact.setEmail("[email protected]");
hibernate pojo setter method problem
); Transaction tx=session.beginTransaction();