Posts

Showing posts with the label hibernate interview questions

Difference between save vs persist and saveOrUpdate in Hibernate

Save vs saveOrUpdate vs persist in Hibernate What is difference between save and saveOrUpdate or Difference between save and persist are common interview question in any Hibernate interview, much like Difference between get and load method in Hibernate . Hibernate Session class provides couple of ways to save object into database by methods like save , saveOrUpdate and persist . You can use either save() , saveOrUpdate() or persist() based upon your requirement for persisting object into Database . Along with Spring framework Interview questions , Hibernate questions are also quite popular on J2EE interviews because of its status as leading ORM. It�s good to prepare some questions from Hibernate before appearing in any J2EE interviews . One of them is Difference between save , saveOrUpdate and persist , which we will see in this Hibernate article. Read more �

Difference between get and load in Hibernate

get vs load in Hibernate Difference between get and load method in Hibernate is a one of the most popular question asked in Hibernate and spring interviews . Hibernate Session class provides two method to access object e.g. session.get() and session.load() both looked quite similar to each other but there are subtle difference between load and get method which can affect performance of application. Main difference between get() vs load method is that get() involves database hit if object doesn't exists in Session Cache and returns a fully initialized object which may involve several database call while load method can return proxy in place and only initialize the object or hit the database if any method other than getId() is called on persistent or entity object. This lazy initialization can save couple of database round-trip which result in better performance. By the way there are many articles on interview questions in Java, you can use search button on top left to fin...