Exam 1z0-900 All QuestionsBrowse all questions from this exam
Question 17

Given the code fragments:

What code should you add to the body of the updateEmployee method in order to save pending changes to the database?

    Correct Answer: A

    In this case, EJBs typically use container-managed transactions, meaning the container automatically handles the transaction boundaries. Because of this, you don’t need to manually manage transactions with UserTransaction or entityManager.getTransaction().begin()/commit(). Therefore, to save the changes made to the Employee entity, using entityManager.merge(emp) in the updateEmployee method is sufficient.

Discussion
orjavaOption: A

Answer: A (container-managed transactions by default not BMT)

devmsalehOption: A

Correct answer is : A

kozionovOption: A

i'm not sure but EJB use container-managed transactions so it doesn’t need to use begin/commit and there is no method entityManager.lock(Object) so correct answer is A

peteVln

Yes, but JPA can be used without a Container, from Java SE, in which case, it is necessary to perform the (mandatory) transactions manually.