|
Answer» - The ADVANTAGES of Hibernate over JDBC are listed below: - Clean Readable CODE: Using hibernate, helps in eliminating a lot of JDBC API-based boiler-plate codes, thereby making the code look cleaner and readable.
- HQL (Hibernate Query Language): Hibernate provides HQL which is closer to Java and is object-oriented in nature. This helps in reducing the BURDEN on developers for writing database independent queries. In JDBC, this is not the CASE. A developer has to know the database-specific codes.
- Transaction Management: JDBC doesn't support implicit transaction management. It is upon the developer to write transaction management code using commit and rollback methods. Whereas, Hibernate IMPLICITY provides this feature.
- Exception Handling: Hibernate wraps the JDBC exceptions and throws unchecked exceptions like JDBCException or HibernateException. This along with the built-in transaction management system helps developers to avoid writing multiple try-catch blocks to handle exceptions. In the case of JDBC, it throws a checked exception called SQLException thereby mandating the developer to write try-catch blocks to handle this exception at compile time.
- Special Features: Hibernate supports OOPs features like inheritance, associations and also supports collections. These are not available in JDBC.
|