• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

A Mock Aboute EntityManager

Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • 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
  • 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);
straws are for suckers. tiny ads are for attractive people.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic