2 Steps hibernate.cgf.xml hibernate.reveng.xml Test Class POJO hbm Create TableAdd LibCreate cfg filehibernate.cgf.xmlCreate reverse eng. filehibernate.reveng.xmlCreate hbm & POJO file from databasePOJORunhbmTest Class
3 Session factory object Test ClassCall configure( )Create Configure class objectReturncfgCall buildSessionFactory( )cfgReturnSession factory objectCall openSession( )scReturnSession objectCall begin Transaction( )sReturnTransaction objectCall save ( )Session objectsemp objectCall commit( )Data Saved into tabletx
4 hibernate.cfg.xmlHibernate requires to know in advance where to find the mapping information that defines how your Java classes relate to the database tables.Hibernate also requires a set of configuration settings related to database and other related parameters.All such information is usually supplied as a standard Java properties file called hibernate.properties, or as an XML file named hibernate.cfg.xml.
9 SessionFactory ?The SessionFactory is a factory of session and client of ConnectionProvider.The SessionFactory is an expensive object to create. It, like the Configuration object, is usually created during application start up.It should be created once and kept for later use.Generally, an application has single SessionFactory and can be shared by all the application threads.It holds second level cache (optional) of data.
11 Session ?The session object provides an interface between the application and data stored in the database.A session wraps a JDBC connection.Think of the Session as a gateway to your database.The instances are light weighted and can be created and destroyed without expensive process.Hibernate Session object represents a single unit-of-work for a given data store and is opened by a SessionFactory instance.Java objects is stored in databases using Session object.It holds a first-level cache (mandatory) of data.
13 Configuration ?It represents a configuration or properties file for Hibernate.The Configuration object is usually created once during application initialization.The Configuration object reads and establishes the properties Hibernate uses to get connected to a database and configure itself for work.A Configuration object is used to create a SessionFactory and then typically is discarded.
18 ConnectionProvider It is a factory of JDBC connections. It abstracts the application from DriverManager or DataSource.It is optional.
19 SQL Dialects in Hibernate For connecting any hibernate application with the database, you must specify the SQL dialects.There are many Dialects classes defined for RDBMS in the org.hibernate.dialect package.
23 Hibernate with Annotation The hibernate application can be created with annotation.There are many annotations that can be used to create hibernate application @Table etc.All the JPA annotations are defined in the javax.persistence.* package.Hibernate EntityManager implements the interfaces and life cycle defined by the JPA specification.The core advantage of using hibernate annotation is that you don't need to create mapping (hbm) file.Here, hibernate annotations are used to provide the meta data.
24 Steps hibernate.cgf.xml JPA Test Class POJO Add Lib Create cfg file Entity POJO ClassAdd JPAPOJOJPARunTest Class
30 Hibernate Query Language (HQL) Hibernate Query Language (HQL) is same as SQL (Structured Query Language) but it doesn't depends on the table of the database.Instead of table name, we use class name in HQL.So it is database independent query language.
31 Advantage of HQL database independent supports polymorphic queries easy to learn for Java Programmer
32 Query InterfaceIt is an object oriented representation of Hibernate Query.The object of Query can be obtained by calling the createQuery() method Session interface.