Posts

Showing posts from May, 2022

Hibernate Interview Questions

  What is a Session in Hibernate? A session is an object that maintains the connection between Java object application and database. Session also has methods for storing, retrieving, modifying or deleting data from database using methods like persist(), load(), get(), update(), delete(), etc. Additionally, It has factory methods to return Query, Criteria, and Transaction objects. What is a SessionFactory? SessionFactory provides an instance of  Session . It is a factory class that gives the Session  objects  based on the configuration parameters in order to establish the connection to the database. As a good practice, the application generally has a single instance of SessionFactory. The internal state of a SessionFactory which includes metadata about ORM is immutable, i.e once the instance is created, it cannot be changed. What is the difference between first level cache and second level cache? Hibernate has 2 cache types. First level and second level cache for whic...