Loading
New on EJB 3.0

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  New on EJB 3.0


Ans)


 Very high level the changes in the proposed EJB 3.0 specification can be divided into two categories:


•An annotation-based EJB programming model, in addition to the EJB 2.1 model of defining
 an application's behavior through deployment descriptors and several interfaces.
•The new persistence model for entity beans. EJB QL has also changed significantly.


Stateless session beans:

A stateless session bean (SLSB), written the EJB 3.0 way,

i) Just a plain Java file with a class-level annotation of @Stateless, interface is not required.
ii) The @Remote annotation can be used to indicate that a remote interface should be generated.

import javax.ejb.*;

@Stateless
@Remote

public class HelloWorldBean {
   public String sayHello() {
      return "Hello World!!!";
   }
}


Entity beans :

i)
Entity beans are marked with the @Entity annotation, and all properties/fields in
the entity bean class not marked with the @Transient annotation are considered persistent.

ii) JPA, the persistence API:

Provides a standard for object-relational mapping (ORM).
• It is not tied to the Java EE containter and can be tested and used with standard Java
• A service provider interface so that the code can be developed independent of the database

and other resources used.

EntityManager manages the transactions and this is Injected by Container into SessionBean
as shown below.

@Stateless
@Remote(Bank.class)
public class BankBean implements Bank {
/**
     * The entity manager object, injected by
        the container
     */
    @PersistenceContext
    private EntityManager manager;

 
public List<Account> listAccounts() {
        Query query = manager.createQuery(
                                  “SELECT a FROM Account a”);
         return;
   }
}



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

New on EJB 3.0


New on EJB 3.0

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free