Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

ejb-3.0

ejb

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?

like image 497
Avraam Mavridis Avatar asked May 19 '13 14:05

Avraam Mavridis


2 Answers

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
like image 180
prem Avatar answered Nov 17 '22 15:11

prem


You are right, these are the main differences between EJB 2 and 3. Generally EJB 3 took all the best from lightweight injection frameworks like Spring and made EJB as close as it is possible to regular POJO.

However today, in the middle of 2013, why do you want to know the difference between EJB2 and EJB3? EJB2 is obsolete. Learn version 3.x, forget about the older versions. Learning EJB 2 these days is exactly like learning horse riding prior to learning car driving because people used to use horses as a transport before invention of cars.

like image 3
AlexR Avatar answered Nov 17 '22 16:11

AlexR