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?
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?
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.
Answer: A (container-managed transactions by default not BMT)
Correct answer is : 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
Yes, but JPA can be used without a Container, from Java SE, in which case, it is necessary to perform the (mandatory) transactions manually.