Introduction to Hibernate, Its Architecture

 

Founder of the Hibernate Open Source Framework
Gavin King is the lead for Hibernate and Craig Russell & David Jordan, the lead authors for SUN-sponsored JDO effort. Due to some technical problems, it appears that the majority in JCP favours Hibernate. The syntax and the approach appear to be almost same with other vendors, but Hibernate syntax is easier to learn. It is interesting to note that Craig Russell works for SUN and Gavin King is now with JBoss. It shows that JCP is a democratic community and SUN is not dictating terms except to protect the language and its enterprise-level users.

Introduction to Hibernate
HIBERNATE is an ORM ( Object-Relational-Mapping) technology. It is an Open-Source and free technology , developed in SourceForge.net in JAVA. There have been a number of such ORM technologies,in recent past.. TopLink is one such tool , subsequently adopted by Oracle and so proprietary. Hibernate from SourceForge and OJB(Object-Relational-Bridge) from Apache are two well known ORM tools, open-source and free. JDO, also falls within the same category.
Advantages of Hibernate in general:
• Writing SQL queries in Java program can be avoided
• Iterating result set is abstracted
• Exception handling is already taken care of in hibernate API and if something programmatically goes wrong we(appn) are thrown with runtime errors
• Support for transactions
• Support for Caching (we can integrate any 2rd party provided caching mechanisms)
• Support for Connection Pooling
Hibernate3.x
Starting from version 3.x, Hibernate is implementing JPA specification. SUN has released this JPA spec under JSR-317. This spec standardizes the basic APIs and the metadata needed for any object/relational persistence mechanism. Any ORM which implements this spec is standardized and using it in our applications makes the application loosely coupled with any ORM vendor so that we can migrate from Hibernate to TopLink if required with minimal changes in the application (provided these two vendors are adhering to standards/spec covered under JPA2 spec released by SUN)

Architecture Diagram


The above diagram shows that Hibernate is using the database and configuration data to provide persistence services (and persistent objects) to the application.
Hibernate has in built support to perform all CRUD operations (Create, Read(select), Update, Delete) operations in ANSI SQL standard and hence it is database vendor independent.
Main components:
• Connection Management
Hibernate Connection management service provide efficient management of the database connections. Database connection is the most expensive part of interacting with the database as it requires a lot of resources of open and close the database connection.
• Transaction management:
Transaction management service provide the ability to the user to execute more than one database statements at a time.
• Object relational mapping:
Object relational mapping is technique of mapping the data representation from an object model to a relational data model. This part of the hibernate is used to select, insert, update and delete the records form the underlying table. When we pass an object to a Session.save() method, Hibernate reads the state of the variables of that object and executes the necessary query.

Hibernate is very good tool as far as object relational mapping is concern, but in terms of connection management and transaction management, it is lacking in performance and capabilities. So usually hibernate is being used with other connection management and transaction management tools.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Mawazo

Mostly technology with occasional sprinkling of other random thoughts

amintabar

Amir Amintabar's personal page

101 Books

Reading my way through Time Magazine's 100 Greatest Novels since 1923 (plus Ulysses)

Seek, Plunnge and more...

My words, my world...

ARRM Foundation

Do not wait for leaders; do it alone, person to person - Mother Teresa

Executive Management

An unexamined life is not worth living – Socrates

Diabolical or Smart

Nitwit, Blubber, Oddment, Tweak !!

javaproffesionals

A topnotch WordPress.com site

thehandwritinganalyst

Just another WordPress.com site

coding algorithms

"An approximate answer to the right problem is worth a good deal more than an exact answer to an approximate problem." -- John Tukey