Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate vs. Entity Beans

Tags:

hibernate

ejb

Whats the advantage of using Hibernate vs entity beans and vice versa ?

I can see the advantages of Hibernate vs JDBC clearly, but I stumbled when I was asked this in the interview.

like image 968
dharag Avatar asked Mar 23 '23 19:03

dharag


2 Answers

From ejb3, there is no concept of entity bean , it has been redefined as JPA. JPA is a spec and it can use any of ORM frameworks as underlying persisting mechanism like Hibernate,OpenJPA, Toplink.

After the JPA specification , The ORM framwork should adhere to the JPA spec. It includes Hibernate too.

Hibernate or JPA can be used in standalone application i.e. it doesnt require any container to be deployed. It can be accessed in a standalone environment.

Thanks

like image 114
Meiyappan Kannappa Avatar answered Apr 01 '23 23:04

Meiyappan Kannappa


According to Oracle EJB Concepts tutorial:

An entity bean represents a business object in a persistent storage mechanism. Some examples of business objects are customers, orders, and products. In the Application Server, the persistent storage mechanism is a relational database.

So Entity Beans are annotated with Java Persistence (JPA) annotations java classes. Hibernate in turn is an implementation of a JPA Spec.

In my opinion there is an advantage of using JPA Spec over Hibernate. This gives you ability to switch the implementation to Toplink, Eclipselink or any other implementation od JPA spec.

like image 34
Sebastian Łaskawiec Avatar answered Apr 01 '23 21:04

Sebastian Łaskawiec