Pages

Sunday, September 9, 2012

What does hibernate do?

Hibernate is an Object relational mapping tool. We normally say it as ORM

say we have an Item object now we have these member variables.

  1. itemPrice
  2. itemName
  3. itemId
Now we need to have a table for this entity. Say the table name is Item then the following columns should be there
  1. item_price
  2. item_name
  3. item_id
If we use normal method

We need to write boiler plate codes for the classes and need to write code to map models with databases.

Another problem is mapping relationships. If we have a Computer class and a MotherBoard class then we need to map MotherBoard object to the computer class as a member variable of computer class.

Also data type conversion has to be done. Say we have a boolean and database stores it as integers. This conversion is also a problem.

It is hard to manage code changes. say we have change in object status. Then we have to write queries for each of the column value  changes. 

what does hibernate do?

Well in simple hibernate removes the inadequacies mentioned above. In simple what hibernate does is it removes the gap between the object and the database. we can persist the object into a database without much effort.

No comments:

Post a Comment