say we have an Item object now we have these member variables.
- itemPrice
- itemName
- itemId
Now we need to have a table for this entity. Say the table name is Item then the following columns should be there
- item_price
- item_name
- 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