Advantage of Hibernate over JDBC
JDBC
|
Hibernate
|
With JDBC, developer has to
write code to map an object model's data to a relational data
model and its corresponding database schema.
|
Hibernate is flexible and
powerful ORM solution to map Java classes to database tables. Hibernate takes care of this mapping using XML files so developer need not write code for this.
|
The mapping of Java objects with database tables and vice versa conversion is to
be taken care of by the developer, the developer needs to write code for this.
|
Hibernate provides
transparent persistence, to map database tables rows to application objects during interaction with
RDBMS.
|
JDBC supports Structured Query Language (SQL). Developer has to find out the efficient way
to access database, i.e. to select effective query from a number of queries to
perform same task.
|
Hibernate provides a
powerful query language Hibernate Query Language. Hibernate also supports native SQL
statements. It also selects an effective way to perform a database
manipulation task for an application.
|
Application using JDBC to
handle persistent data having database specific code. The code is written to map table fields to object properties. As table
changes or database changes then it is essential to change object structure as
well to map table-to-object/object-to-table.
|
Hibernate provides this
mapping. The actual mapping between tables and application objects is
done in XML files. If there is change in Database or in any table then the
only need to change XML file properties.
|
With JDBC, it is
developer’s responsibility to handle JDBC result set and convert it to Java
objects through code to use this persistent data in application.
|
Hibernate reduces lines of
code by maintaining object-table mapping and returns result to
application in form of Java objects. It relieves programmer from manual
handling of persistent data, hence reducing the development time and
maintenance cost.
|
With JDBC, to enable caching the developer needs to write the code for caching of Objects
|
Hibernate, has its own caching facility, instead of coding for the caching feature, the developer just configures caching through configuration files.
|
In JDBC there is no check
that always every user has updated data. This check has to be added by the
developer.
|
Hibernate enables developer
to define version type field which updates database table every time a row is updated in form of Java object to that table.If two users
retrieve same row and modify it and one user save this modified row to database, version is automatically updated for this row by Hibernate.
When other user tries to save updated row to database then it does not
allow saving it because this user does not have updated data.
|
Happy to found this blog. Good Post!. It was so good to read and useful to improve my knowledge as updated one, keep blogging. Hibernate Training in Electronic City
ReplyDeleteJava Training in Electronic City