Why hibernate is advantageous over Entity Beans & JDBC?- An entity bean always works under the EJB container, which allows reusing of the object external to the container. An object can not be detached in entity beans and in hibernate detached objects are supported.
- Hibernate is not database dependent where as JDBC is database dependent. Query tuning is not needed for hibernate as JDBC is needed. Data can be placed in multiple cache which is supported by hibernate, whereas in JDBC the cache is to be implemented.Why hibernate is advantageous over Entity Beans & JDBC?- In hibernate, Session Cache or collection of loaded objects relates to a single unit of work. In EJB, Persistence Context-Set of entities that can be managed by a given EntityManager is defined by a persistence unit.
- Hibernate defines HQL for expressing queries to the database. EJB defines EJB QL for expressing queries
- Entity Relationships are unidirectional. Bidirectional relationships are implemented by two unidirectional relationships. Entity Relationships are bidirectional or unidirectional
- 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. 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.
- 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.
- 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.
- 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.
|