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

2

12

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?

Liripipe answered 19/5, 2013 at 14:14 Comment(0)
L
23

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
Lite answered 15/7, 2014 at 11:26 Comment(0)
S
3

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.

Shady answered 19/5, 2013 at 14:21 Comment(3)
even if i agree with your answer i couldn't resist sharing with all of you that right now in my current job in 2015 EJB2 are used everywhere. There are some plans to migrate to EJB3, though. Go figure!Surah
@jambriz, in company where my wife works they use Cobol. This does not mean however that this language is obsolete and I do not see any reason (except total crash of hi-tech industry) to learn this language.Shady
true. any EJB3 specific tutorials plsMatthewmatthews

© 2022 - 2024 — McMap. All rights reserved.