• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

Given:
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);
 
reply
    Bookmark Topic Watch Topic
  • New Topic