Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Hibernate-Interview-Questions session.save , session.saveOrUpdate, and session.persist
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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


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


Advertisement
View Answers

March 7, 2011 at 4:58 PM


Hi Samar, 
session.save() : 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 session.save(). 
But session.save() return Serializable object but session.persist() return void. 
         session.save() returns the generated identifier (Serializable object) and session.persist() doesn't.


Related Tutorials/Questions & Answers:
session.save , session.saveOrUpdate, and session.persist
session.save , session.saveOrUpdate, and session.persist  Difference between session.save() , session.saveOrUpdate() and session.persist
Difference between session.save() , session.saveOrUpdate() and session.persist() in Hibernate
Difference between session.save() , session.saveOrUpdate() and session.persist...() , session.saveOrUpdate() and session.persist()in Hibernate?   session.save... data. session.persist() : Does the same like session.save(). But session.save
Advertisements
Hibernate : Session Save
In this section we will discuss how session.save() works in Hibernate
Hibernate save Example - Rose India Hibernate 4 tutorials
saved the object using the Session.save() method. Here in this section we..."); emp.setEmpAddress("Delhi - India"); session.save(emp); tr.commit... the session.save(emp)  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 session.save(obj);  Hi I am sending a link where u can find lots of example related to hibernate... http://www.roseindia.net/hibernate
ramanjaneyulu
ramanjaneyulu  where is the SQL statement in this example? i mean when we call session.save() 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 session.save() and other methods... will save the object in database if session.save() and other methods are callled
library
); s2.getCourses().add(c2); session.save(s1); session.save(s2
How to insert data from textfields into database using hibernate?
(IdCantitateTextField); produs.setUnitMas(UnitMasTextField); session.save(produs
Hibernate session.refresh() method
. session.refresh() reload all the data. No nned again to select call. session.save(cat
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("deepak_38@yahoo.com"); session.save..."); contact.setEmail("amar_05@yahoo.com"); session.save(contact); tr.commit
Hibernate Basic Example not working
"); session.save(book); System.out.println("Done"); }catch(Exception e
Struts2.2.1 and hibernate integration application
(); session.beginTransaction(); session.save(obInformation
java(Hibernate) - Hibernate
); System.out.println("user.setPhoneNumbers(s)"); //To Insert record throw { session.save(user); System.out.println("session.save(user)"); tx.commit..."); user.setPhoneNo("9810254612"); session.save(contact); session.save(user
hibernate code - Hibernate
"); contact.setEmail("deepak_38@yahoo.com"); session.save(contact
java
(); session.save(staffing); serealNo = (int)staffing.getSlNo...(); session.save(users); System.out.println("got sl no in registor Dao
Reagrsding Hibernate joins - Hibernate
;); con.setState("bihar"); session.save(con); session.save(contact); tr.commit(); System.out.println("Done"
hibernate firstExample not inserting data - Hibernate
"); session.save(contactBO); System.out.println("After Save"); } catch..."); contact.setEmail("deepak_38@yahoo.com"); session.save(contact
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
"); session.save(emp); tr.commit(); System.out.println("Successfully inserted..., sets the values and finally calls the session.save(emp)  to save... to use Hibernate's session.save() method to save the data in our example
Problem in running first hibernate program.... - Hibernate
"); session.save(contact); System.out.println("Done"); }catch(Exception...); tx = session.beginTransaction(); session.save(contact
Hibernate Many One One Mapping
* Student("Syam", address); session.save(ram); session.save(syam...); Student syam = new * Student("Syam", address); session.save(ram); session.save(syam); * * transaction.commit(); */ And comment the following
Hibernate Transaction
;); session.save(person); tx.commit(); System.out.println("Done"
Hibernate Architecture
the underlying table. When we pass an object to a Session.save() method, Hibernate
in connectivity - Hibernate
"); contact.setEmail("vinod@rediffmail.com"); session.save(contact
Advertisements
 

 

 

DMCA.com