What is the advantage of Hibernate over jdbc?- The advantages of Hibernate over JDBC are:
1. Hibernate code will work well for all databases, for ex: Oracle,MySQL, etc. where as JDBC is database specific.
2. No knowledge of SQL is needed because Hibernate is a set of objects and a table is treated as an object, where as to work with JDBC, one need to know SQL.
3. Query tuning is not required in Hibernate. The query tuning is automatic in hibernate by using criteria queries, and the result of performance is at its best. Where as in JDBC the query tuning is to be done by the database authors.
4. With the support of cache of hibernate, the data can be placed in the cache for better performance. Where as in JDBC the java cache is to be implemented.What is the advantage of Hibernate over jdbc?1. Developer has to write code in JDBC to map an object model's data representation to a relational data model and its corresponding database schema.
2. Hibernate itself takes care of this mapping using XML files so developer does not need to write code for this. JDBC supports only native Structured Query Language (SQL). Hibernate provides Hibernate Query Language (HQL) which is similar to SQL syntax and supports polymorphic queries too. It also supports native SQL statements.
3. The mapping of Java objects with database tables has to be taken care of in JDBC. Hibernate provides transparent persistence and therefore there is no need to map database tables tuples to application objects during interaction with RDBMS.
4. With JDBC, caching needs to be manually maintained. Hibernate cache is set to application work space. Relational tuples are moved to this cache as a result of query. It improves performance during multiple writes for the same data.
5. In JDBC there is no check that always every user has updated data. Hibernate enables definition of version type field to application, due to which Hibernate updates version field of database table every time relational tuple is updated in form of Java class object to that table.
|