Before creating the Hibernate application we need to know about the elements of hibernate which need to use in hibernate. So those elements we use in hibernate are as below:
1. SessionFactory: SessionFactory is an interface, which is available in “org.hibernate” package. Session factory is long live multithreaded object. SessionFactory is a combination of session and client of ConnectionProvider. It holds second level cache (optional) of data. The org.hibernate.SessionFactory interface provides factory method to get the object of Session.
2. Session: Session object provides an interface between the application and data which stored in the database. It is a short-lived object and wraps the JDBC connection. It is factory of Transaction, Query and Criteria. It holds a first-level cache (mandatory) of data.
org.hibernate.Session interface provides methods to insert, update and delete the object. It also provides factory methods for Transaction, Query and Criteria.
3. Transaction: The transaction object specifies the atomic unit of work. It is optional. In the org.hibernate.Transaction interface provides methods for transaction management.
4. ConnectionProvider: It is a factory of JDBC connections. It abstracts the application from DriverManager or DataSource. It is optional.
5. TransactionFactory: It is a factory of Transaction. It is optional.