File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes A Mock Aboute EntityManager Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "A Mock Aboute EntityManager" Watch "A Mock Aboute EntityManager" New topic
Author

A Mock Aboute EntityManager

Fu Dong Jia
Ranch Hand

Joined: May 23, 2007
Posts: 131
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?


who dare win!<br />SCJP5(94%)|SCWCD5(86%)|SCBCD(100%)|SCEA in progress
Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 402
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);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A Mock Aboute EntityManager