Thursday 24 November 2016

Differences between EJB 2 and EJB 3

Differences between EJB 2 and EJB 3 | Java Source World


Differences between EJB 2 and EJB 3 :



Lets find the some differences between EJB 2.0 and EJB 3.0 below:


                   EJB 2.0
                  EJB 3.0
EJB 2.0 uses the entity Beans for accessing the databases.
EJB 3.0 uses the JPA to access the database.
EJB 2.0 needs deployment description.
There is no requirement of deployment description while using EJB 3.0.
In EJB 2.0, we have to write Home and Remote interface to have access the databases.
EJB 3.0 does not have such constraint and is more convenient in this regard.
Security issues are handling through Deployment descriptors in EJB 2.0.
EJB 3.0 is using annotation.
EJB 2.0 has limitation in its pluggability with third party persistence providers.
These limitations not exist in EJB 3.0.


What are Enterprise Beans



Here below lets find some more differences between EJB 2.1  and EJB 3.0.

1) EJB 3.0 is much faster than EJB 2.


2) An EJB 2.1 session bean must implement the SessionBean interface. But an EJB 3.0 session bean does not implement the SessionBean interface.


3) An EJB 2.1 session bean includes one or more ejbCreate(), ejbPostCreate(), ejbActivate(), ejbPassivate(), ejbRemove(), and setSessionContext(), and the business methods defined in the local/remote interface. Whereas an EJB 3.0 session bean class includes only business methods.


4) EJB 2.1 includes home interface that extends the EjbHome interface, remote interface that extends the javax.ejb.EJBObject interface, local home interface that extends the javax.ejb.EJBLocalHome interface, and local interface that extends the javax.ejb.EJBLocalObject interface. EJB 3.0 interfaces are POJI (Plain Old Java Interface) business interfaces and do not require home and component interfaces.


5) EJB 2.1 must have the deployment descriptor. EJB 3.0 may or may not contain deployment descriptors. Annotations are added to the language that can serve almost all the purposes that were previously served by the deployment descriptor.


6) An EJB 2.1 Entity EJB bean class must implement the EntityBean interface and must provide implementation to the ejbCreate() and ejbPostCreate() methods. EJB 3.0 entities are persistent objects that are not required to implement the EntityBean interface.


7) EJB 2.1 entity bean includes the home, component, local home and local component interfaces that extend the EJBHome, EJBObject, EJBLocalHome and EJBObject interfaces respectively. EJB 3.0 entities are Plain Old Java Objects (POJO) and do not require home and component interfaces.


8) An EJB 2.1 bean must define resource-ref in ejb-jar.xml to lookup resources. An EJB 3.0 bean can use either dependency injection or JNDI lookup.


9) An EJB 2.1 message-driven must implement the javax.ejb.MessgeDrivenBean interface. An EJB 3.0 message-driven may or may not implement the javax.ejb.MessgeDrivenBean interface.


10) EJB 3 introduced persistence API for database access. In EJB 2 you can use Entity bean.



Related posts:





No comments:

Post a Comment