1: what is Hibernate?
A Hibernate is an Object Relational Mapping and persistent framework that helps to map plain Java objects to relational database. By using the XML configuration file, it can be mapped into those relational database tables. In fact, it can able to perform the CURD operations and write HQL queries. It has a facility to specify the metadata between the objects. Also, it has to perform the Dirty checking and lazy association fetching.
2: why and how does hibernate help in programming?
The main motto of the hibernate framework is to provide shielding for developers to write messy SQL queries. Apart from this, it can able to improve the productivity of the developer to execute the high level object oriented API. It helps to write, the less Java code to write. While using the hibernate, it can used to improve the performance by offering the sophisticated caching. Moreover, it could able to generate database for SQL.
3: how to configure Hibernate?
In order to configure hibernate, you need to execute the code as hibernate.cfg.xml or hibernate.properties file and *.hbm.xml files. These files are used to configure the class to create a session factory in it. Also, it can used to configure the services by providing the driver class, database connections, user name, and password for accessing it.
4: what is the role of session interface in Hibernate?
It is the primary interface that is used in the Hibernate application. In addition, a single threaded sort object that can be represents between the application and persistent store. In order to retrieve the persistent objects, it can be able to create query objects.
Session session= sessionFactory.openSession ();
It may also hold the mandatory cache for the first level of persistent objects and to navigate the object graph or by identifier.
5: what are the different types of caches in Hibernate?
There are two types of caches are used in the hibernate framework.
- First-level cache
- Second-level cache
The first level cache is associated with session objects, whereas second level cache is associated with sessionFactory object. While using the default option, it can specify the first level cache on a transaction basis.
6: define Hibernate Template?
In order to simplify the data access code, this Hibernate Template is to be specified and used. In fact, it is a helper class that can able to access the data code. Hence, this class can supports automatically to convert the hibernate exceptions which is a checked exception into data access one to implement data.
7: what is a Hibernate proxy?
A mapping of classes can be made into a proxy instead of using the table. This will used to return the load and often called as a session. It can also contain an actual method to load the data and used to create by default hibernate to map a class file.