Which code, when added to the stateless session bean class, injects a container-managed persistence context at runtime?

A developer writes an enterprise application and packages it into an enterprise archive (EAR). The
application contains one persistence unit with unit name “FooPU”. The application also contains
an ejB. jar with one stateless session bean. Which code, when added to the stateless session
bean class, injects a container-managed persistence context at runtime?

A developer writes an enterprise application and packages it into an enterprise archive (EAR). The
application contains one persistence unit with unit name “FooPU”. The application also contains
an ejB. jar with one stateless session bean. Which code, when added to the stateless session
bean class, injects a container-managed persistence context at runtime?

A.
@PersistenceContext
EntityManager em;

B.
@Resource(unitName=”FooPU”)
EntityManager em;

C.
@PersistenceUnit(unitName=”FooPU”)
EntityManager em;

D.
@PersistenceContext(unitName=”persistence/FooPU”)
EntityManager em;



Leave a Reply 0

Your email address will not be published. Required fields are marked *