aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes EJB3 in Action errata for EntityManager.refresh() method 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 "EJB3 in Action errata for EntityManager.refresh() method" Watch "EJB3 in Action errata for EntityManager.refresh() method" New topic
Author

EJB3 in Action errata for EntityManager.refresh() method

Tyronne Fernando
Ranch Hand

Joined: May 11, 2008
Posts: 50
The following section is from EJB 3 in Action page 299.

"An entity can become attached to the EntityManager’s context when you pass the entity to the persist, merge, or refresh method."

Does the entity get attached to the persistence context when it passed to the refresh() method or is this an error in the book?

Thanks in advance.
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3106
    
  41

Which makes you to think that the entity will not get attached to the PC by the refresh() method?
And, "Tyronne Fernando", is that your real name?


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Tyronne Fernando
Ranch Hand

Joined: May 11, 2008
Posts: 50
The following code and text is from page 332 of EJB 3 In Action:

public Item undoItemChanges(Item item) {
entityManager.refresh(entityManager.merge(item));
return item;
}

"The merge operation is performed first in the undoItemChanges method because the refresh method only works on managed entities."

Because of this, I get the impression that the refresh() method does not attach the entity to the persistence context.

.... and Tyronne Fernando is my real name
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB3 in Action errata for EntityManager.refresh() method