• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
  • Frits Walraven
  • fred rosenberger
  • salvin francis

A Mock Aboute EntityManager

Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

11. @PersistenceContext EntityManager em;
12. public boolean test(Order o) {
13. boolean b = false;
14. o = em.merge(o);
15 em.remove(o);
16. o = em.merge(o);
17. b = em.contains(o);
18. return b;
19. }
Pass4Side SUN 310-091
Pass4Side Help you pass any IT Exams! Page 5 of 9
Which statement is correct?
A. The method will return TRUE.
B. The method will return FALSE.
C. The method will throw an exception.
D. The Order instance will be removed from the database.
Answer: C

Why the answer is c?
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
javadocs of EM for merge

* Merge the state of the given entity into the
* current persistence context.
* @param entity
* @return the instance that the state was merged to
* @throws IllegalArgumentException if instance is not an
* entity or is a removed entity
* @throws TransactionRequiredException if invoked on a
* container-managed entity manager of type
* PersistenceContextType.TRANSACTION and there is
* no transaction.
public <T> T merge(T entity);
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic