Hibernate,
Powerful ORM solution to map Java classes to database tables. It can be done using
XML mapping files. In JDBC, it is developer’s
responsibility to handle JDBC result set and convert it to Java objects done
manually.
Hibernate supports caching
mechanism which reduce the number of round trips between an application and the
database automatically, which result to application performance. But in JDBC, caching is
maintained by hand-coding.
Hibernate
provided Dialect classes, so we no need to write SQL queries in hibernate,
instead we use the methods provided by that API.
Hibernate
has its own query language HQL (hibernate query language) which is database
independent. If we want to change the database, we need to update the Dialect
only. But in case of JDBC, we need to update all SQL
queries.
This
will also supports collections like List, Set, and Map (Only new collections).
Hibernate
only have Un-checked exceptions, so no need to write try, catch, or no need to
write throws. Actually in hibernate we
have the translator which converts checked to Un-checked. But in JDBC, all exceptions are checked exceptions, so we
must write code in try, catch and throws.
Getting
pagination in hibernate is quite simple.
Hibernate
has capability to generate primary keys automatically while we are storing the
records into database.
Hibernate,
if it will not found any table in the database while inserting any record this
will create the table. But in case of JDBC will raise
an error like “View not exists”, and throws exception.
No comments:
Post a Comment