Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Hibernate Hibernate4.3 Hibernate Overview and Architecture

Related Tutorials


 
 

Share on Google+Share on Google+

Hibernate Overview and Architecture

Advertisement
In this article you will be introduced with the Hibernate framework and you will understand its architecture.

Hibernate Overview and Architecture - Learn the basics of the Hibernate ORM framework

This article is providing the overview of the Hibernate framework and discussing about the Architecture of the Hibernate ORM.

Here we will discuss about Hibernate Architecture. Hibernate has a layered architecture making it easy for developers to select between core components and other components. Hibernate is used to develop data access layer of Java applications. It can work with applications based on both JSW and JEE.

Hibernate can be configure in two ways-using configuration file named hibernate.cfg.xml and by using *.hbm or Annotated POJO classes.

Hibernate uses POJO's and saves its to database table. It uses the configuration files and annotation to provide the metadata to the ORM system. You can easily use the persistent object (POJO) classes in your application and use Hibernate to persist it to the datbase. Meta-data is used to map the instance variable in the class with the columns in the database. Hibernate automatically generates SQL query to perform operations like select, insert, update and delete.

Java APIs like JDBC, JTA(Java Transaction API) and JNDI(Java Naming and Directory Interface) are used between Hibernate and database server.

Hibernate Architecture

The above diagram shows how hibernate works.

Here is how hibernate works (Hibernate Architecture explained):

To preserve data an Entity class mapped with database table is managed by Hibernate. At the same time an instance of SessionFactory is used to get the Session object which is the main interface between your application and database. Session factory implements Factory design and loads hibernate.cfg.xml file. Session object used to interact with the database through the methods of the interface.

Hibernate Configuration:

Configuration class perform two operations-database connection and class mapping setup. hibernate.cfg.xml is used to configure the database connection. Class mapping creates the link between java classes and database tables.

Hibernate SessionFactory:

SessionFactory creates Session instances to communicate with the database. Whenever application starts, SessionFactory object is created. It is a thread safe. There is one SessionFactory for each database. SessionFactory is created in configuration file.

Multiple SessionFactory objects are created when we need more than one database.

Hibernate Session:

Hibernate Session is runtime interface between application and hibernate. Session object saves and retrieves persistent objects. You can create and destroy Session object as and when you need.

Caution: Session object is not thread safe, do not open it for long time.

Hibernate Transaction:

Hibernate Transaction is single threaded object used for a unit of work with the database. Transaction manager handle your transactions.

Hibernate Query:

Hibernate provide simple SQL, native query and HQL for performing different database operations. Instance of Query is found by Session.createQuery().

Hibernate Criteria:

Hibernate Criteria is used to retrieve objects. Criteria objects performs database operations.

Components of Hibernate Architecture:

Hibernate Connection Management allows management of database, which requires lot of resources to open and close the database connection.

Hibernate Transaction Management allows user to execute several database statements at a time.

Object Relational Mapping (ORM): maps the data representation from an object model to a relational database.

Hibernate architecture is also known as Full Cream architecture when three components are used together and is called as Lite architecture if only ORM component is used.

Learn the basics of Hibernate Basics:

The latest version of Hibernate is 4.3.x. Read the complete tutorial of Hibernate 4.3.x.

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 31, 2013

Related Tutorials

Discuss: Hibernate Overview and Architecture  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com