03. ORM - JDBC vs Hibernate
JDBC vs Hibernate
JDBC |
Hibernate |
JDBC is database specific Hibernate generate the queries by itself at
runtime based on the given dialect. Dialect is specific with the database. Within
the same application, today we use oracle, tomorrow MS-SQL, day after tomorrow
mongo DB etc... But we don’t want to change our application code. Only thing
we have to do is changing the dialect according to the database. Only thing we have to do here is we want to
change the dialect according to the database which we are using. That’s |
Hibernate is database
independent |
Does not support for caching. Caching improves
the performance of an application by reducing database hits |
In the hibernate
Support the caching. There are two type of caching can be seen (first
level caching [for one session] and second level caching [for multiple
session]). |
In JDBC, developers have is the responsibility to
handle JDBC result set and convert to java. User has to manually populate the
object from the result set. |
There is no manual conversion
of result set to object and it is done by hibernate (reduce development time and
maintain cost). |
We need to implement our own connection pooling mechanism.
More chance -> to connection leakage in JDBC |
In the hibernate we
can use connection pooling |
In the JDBC user is responsible for creating and
closing the connection |
Hibernate take care
about creating and closing the connection at runtime. |
JDBC is a technology Whatever the code which we write in order to
perform CURD operation we need to write ourselves. But in the hibernate, there
are many predefined methods to perform CURD operation. Not only that hibernate
has caching and connection pooling also. |
Hibernate is a framework |
Comments
Post a Comment