Question : Why JPA Entity or Hibernate Persistence Class Should Not be Final?
Answer : One of the interesting hibernate interview questions is, why you should not make a Hibernate persistent class final? I'll try to answer this question in this short blog post. The use of proxies is the core feature of Hibernate (one of the most popular ORM frameworks for Java Projects) for implementing key performance features e.g. lazy loading and lazy associations fetching. In order to use a proxy in place of a real class, your hibernate persistence class must be either non-final or the implementation of an interface that declares all of the public methods.
Difference between save vs persist and saveOrUpdate in Hibernate
Save vs. saveOrUpdate vs. persist in Hibernate?
What is the difference between save and saveOrUpdate or Difference between saving and persist are common interview question in any Hibernate interview, much like the difference between get and load method in Hibernate. Hibernate Session class provides a couple of ways to save an object into the database by methods like save, saveOrUpdate, and persist. You can use either save(), saveOrUpdate() or persist() based upon your requirement for persisting objects into the database. The key thing is that all these objects are used to store data into the database but they also make a transient object persistent in Hibernate.
J2EE
Difference between get and load in Hibernate
get vs load in Hibernate ?
Difference between get and load method in Hibernate is one of the most popular questions asked in Hibernate and spring interviews. Hibernate Session class provides two methods to access object e.g. session.get() and session.load() both looked quite similar to each other but there are subtle differences between load and get method which can affect the performance of the application. The main difference between get() vs load method is that get() involves database hit if an object doesn't exist in Session Cache and returns a fully initialized object which may involve several database calls 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.
Comments
Post a Comment