1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc)

Hibernate interview questions

!!! Hibernate interview questions !!!

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




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.
For Example :
         if you do :-
         System.out.println(session.save(question));
         This will print the generated primary key.
         if you do :-
         System.out.println(session.persist(question));
         Compile time error because session.persist() return void.

The information you are posting should be related to java and ORACLE technology. Not political.