EJB Vs Hibernate

EJB Vs Hibernate
  • In case of EJB’S entity beans, we should require 1-1 relation between database table and the entity classes. But it is not mandatory in case of hibernate. In case of hibernate, a single entity class may represent multiple no.of tables and single table may represent multiple no.of entity classes.
  • EJB’S entity beans is more API dependent because in EJB’S entity beans all the entity classes must implement or extend predefined library provided by EJB API.
  • Hibernate is less API dependent because in Hibernate all the entity classes are by default POJO classes(plain old java object),these are normal java bean classes which should not extend (or) implement any predefined library.
  • Due to the above reasons, Testing & Debugging is very difficult in entity but which are very simple in case of Hibernate.
  • In case of entity beans, all the bean classes are not participated in inheritance directly. But in case of hibernate, it is possible to provide inheritance relation b/w POJO classes.
  • EJB’S entity beans should require application server to execute. But hibernate applications will be executed with or without application server.
  • Due to the above reasons, entity beans portability is very less. Due to the above reason, hibernate portability is very good.
  • Due to the above reason entity bean is heavy weight data persistency solution. Due to the above reason, hibernate is light weight data persistency solution.
  • Entity beans are relatively slow and hibernate is faster data persistency solution except startup.
EJB Vs Hibernate
Scroll to top