Programming Overhead
- In JDBC, it is developer’s responsibility to handle JDBC result set and convert it to Java objects done manually.
- Hibernate (as an ORM) maps Java classes to database tables automatically, thus reduces programming overhead and development time.
Caching and Connection pooling
- In JDBC, caching and connection pooling is maintained by hand-coding.
- Hibernate provides excellent caching support and connection pooling for better application performance.
DB independent
- Hibernate has its own query language (HQL) which is database independent. If we want to change the database, we need to update the Dialect only.
- In case of JDBS, we need to update all SQL queries.
Transaction Management
- In JDBC one has to explicitly handle transaction management in the code.
- Hibernate provides injected transaction management.
Concurrency Support
- In JDBC there is no check that always every user has updated data this check has to be added by the developer.
- Hibernate maintains this concurrency check using a version field. It checks this version field in the database table before every update operation.
If two users retrieve data from the same table and modify it and if one of them saves the modification, the version gets updated.Now when the second user tries to save his data hibernate doesn't allow it because the data he retrieved was modified and his version doesn't match with the version in the database.
Exception handling
- 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.
- In JDBC, all exceptions are checked exceptions, so we must provide exception handlers.
Automatic Table creation
- Hibernate, if it will not found any table in the database while inserting any record this will create the table.
- In case of JDBC will raise an error like “View not exists” and throws exception.
Auto-generate primary keys
- Hibernate has capability to generate primary keys automatically while we are storing the records into database.
Pagination support
- Getting pagination in hibernate is quite simple.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.