What are the main differences between EJB 2.0 and EJB 3.0 in the orientation of an object

Avraam Mavridis picture Avraam Mavridis · May 19, 2013 · Viewed 25.7k times · Source

I want to try EJB and I am studying the theory behind EJB 3.0. I know that in EJB 3.0 you don't have to use deployment descriptor but you can use annotations, and also you don't have to write Home and Remote Interfaces.

Are there any other key difference in the object orientation between EJB 2.0 and EJB 3.0?

Answer

prem picture prem · Jul 15, 2014

Major difference between EJB 2.0 and 3.0 are listed below in theory

  1. Elimination of home interface gives simpler lookup process in EJB 3.0 than in EJB 2.0.
  2. Employment of annotations makes EJB 3.0 a latest technology while the EJB 2.0 has home and remote interfaces instead of annotations.
  3. EJB 2.0 deploys entity beans for accessing database. EJB 3.0 has Java Persistence API to access data which is generalized to address issues of portability.
  4. EJB 3.0 performs better because it uses POJOs along with metadata annotation, a new introduction. The POJOs are faster than XMLDescriptor and JNDI deployed by EJB 2.0 for reference of objects. EJB 2.0 does not implement POJO.
  5. EJB 2.0 is heavy when it comes to writing home and remote interfaces. EJB 3.0 has no restriction on using any of the standard interfaces. It is a well configured and simple POJO which doesn’t need to execute container callback methods such as ejbActive, ejbStore, etc which are used by EJB 2.0.
  6. In EJB 3.0, entity bean can be effortlessly converted to DAO and vice versa. This is not possible in EJB 2.0.
    Hope this might help to some extent