Hibernate Over JDBC

May 1st, 2011No Comments

Limitations of JDBC:-

1. Connection management is complex.
2. If the database schema modified after JDBC application is developed then again we need to reopen and we need to modify the JDBC application. It means debugging of JDBC application is complex.
3. JDBC only transfers data between an application and database in the form of text but not in the form of object.

4. JDBC doesn’t supports associations (Relations Ships) like one to many, many to many, etc., and inheritance also.
5. In a enterprise application development the business logic will be implemented in the form of objects and data transforms with in the application also on the form of objects. But when persistency the data using JDBC then the data that exist in objects will be translated in to text format and then this data will be persisted to a database.
6. Instead of transferring the data in text format for persisting to a database we can also transfer objects between a java application and a database using hibernate.
7. Hibernate is a light weight ORM (Object Relational Mapping) tool for providing data access layer for an application.
8. Hibernate is a single java based middle ware to communicate across multiple Data Sources (Databases).
9. Hibernate is a non-invasive framework. It means hibernate doesn’t force a programmer to extend or implement the programmer class from any framework given class or interface
10. Hibernate runs with in a server / with out a server (standalone [desktop] or application server).
Swings + hibernate  Desk top
Struts + hibernate  server side
11. Mapping a java class to a table in relational database is set to be ORM (Object Relational Mapping).
12. In ORM the properties of an object will be mapped to column of a table.
13. Placing an object attributes in to a table column is also said to be ORM.
14. As part of hibernate we need the following 3 files tp persist the data in the form of objects.

I. A Pojo Class
II. A Mapping File
III. A Configuration File

Pojo Class: -

–> It is a normal java class which contains variables along with setter and getter methods.

–> Some times a pojo class also becomes like a Java Bean.

Note: – Each Java Bean is a Pojo but each Pojo is not a Java Bean.

Mapping File: -

–> It is an XML file which contains mapping from class to a table and a pojo class variable to table columns.

–> A mapping file of hibernate is identified with . hbm.xml.

–> With in a hibernate application we can create one or more hbm.xml files for one or more classes.

Configuration File: -

–> It is an xml file which contains the following 3 properties

a. Connection Property
b. Hibernate Property
c. Mapping File Names

–> We need configuration file for communicating with database.

–> A configuration file is identified with . cfg.xml

Benefits of Hibernate: -

–> Hibernate supports inheritance, associations and collections

–> Hibernate provides caching mechanism which reducing the number of round trips between an application and database server.

–> Hibernate supports caching at 2 levels

i. First Level Caching / Session Cache
ii. Second Level Caching

–> Hibernate provides different “dialects” for different databases so the application programmer no need to write any sql commands the programmer uses API methods. API methods are translated into sql commands by the “dialects”.

–> Hibernate provided HQL (Hibernate Query Language) criteria API for bounding multiple objects from database into application by providing connection.

–> Hibernate supports pagination which will be used when developing the web application etc.,

VN:F [1.9.10_1130]
Rating: 9.2/10 (5 votes cast)
VN:F [1.9.10_1130]
Rating: +1 (from 3 votes)

Hibernate Over JDBC, 9.2 out of 10 based on 5 ratings

About author:

All entries by

Leave a Reply