Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam 1z0-900 topic 1 question 18 discussion

Actual exam question from Oracle's 1z0-900
Question #: 18
Topic #: 1
[All 1z0-900 Questions]

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?

  • A. entityManager.merge(emp);
  • B. Context. Ctx = new InitialContext(); UserTransaction utx = (UserTransaction)ctx.lookup("java:comp/UserTransaction"); utx.begin(); entityManager.merge(emp); utx.commit();
  • C. entityManager.lock(emp); EntityManager.merge(emp);
  • D. entityManager.getTransaction().begin(); entityManager.merge(emp); entityManager.getTransaction().commit();
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
orjava
3 months, 2 weeks ago
Answer: A (container-managed transactions by default not BMT)
upvoted 1 times
...
devmsaleh
1 year, 7 months ago
Correct answer is : A
upvoted 1 times
...
kozionov
2 years, 4 months ago
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
upvoted 1 times
peteVln
3 months, 3 weeks ago
Yes, but JPA can be used without a Container, from Java SE, in which case, it is necessary to perform the (mandatory) transactions manually.
upvoted 1 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...