Oracle
1Z0-860 · Question #87
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…
The correct answer is A. @PersistenceContext EntityManager em. See the full explanation below for the reasoning.
Question
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?
Options
- A@PersistenceContext EntityManager em;
- B@Resource(unitName="FooPU") EntityManager em;
- C@PersistenceUnit(unitName="FooPU") EntityManager em;
- D@PersistenceContext(unitName="persistence/FooPU") EntityManager em;
How the community answered
(51 responses)- A71% (36)
- B10% (5)
- C16% (8)
- D4% (2)
Community Discussion
No community discussion yet for this question.