Magazine
 
Hibernate
 
Hibernate 3-Tier Architecture

The above diagram shows the Enterprise (3- tier) architecture of Hibernate in which, a Session EJB that manipulates persistent objects may use Hibernate.

Basically, Hibernate architecture has three main components:

Connection Management:

Hibernate connection management services provide well-organized management of the database connections. Database connection is the most expensive part for interacting with the database, as it requires a lot of resources to open and close the database connection.

Transaction Management:

Through this service, the user can execute more than one database statements at a time.

Object Relational Mapping: It is a technique of mapping that maps the data representation from an object model to a relational data model. This component is used to select, insert, update and delete the records to and form the underlying table. When we pass an object to a Session.save() method, Hibernate reads the state of that object and executes the necessary query.

Hibernate provides a lot of flexibility to the applications interacting with the database. When we use only the object relational mapping component it is called “Lite” Hibernate architecture. While all three components (Object Relational mapping, Connection Management and Transaction Management) are used during data-configuration then Hibernate architecture is called “Full Cream” architecture.

Creating First Hibernate Application

In this section, we are going to develop first Hibernate application that insert a record into the database using Hibernate. You can run this program from Eclipse or from command prompt as well.

To create a Hibernate application, do the following steps:

  • Preparing Database
  • Creating persistent java objects
  • Mapping the POJO’s Objects to the Database table using hibernate mapping document
  • Hibernate Configuration File
  • Hibernate Sample Code Test (Inserting new record)
  • Running the Hibernate application

I. Preparing Database

Let’s consider a simple database schema named “hibernatetutorial” with a single table as “CONTACT”. This table has four fields with a primary key field “ID”.

Dec 2007 | Java Jazz Up |28
 
previous
index
next
 
View All Topics
All Pages of this Issue
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , 80 , 81 , 82 ,

Download PDF