wood burning stoves 2.0*
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: 3018
    
  35

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?


Founder of ExamLab and Systemup
See how I can help you to become an awesome programmer
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
 
Consider Paul's rocket mass heater.
 
subject: EJB3 in Action errata for EntityManager.refresh() method
 
Similar Threads
find and getReference methods
EntityManager
Doubts about refresh + merge function in JPA
Entitymanager.refresh doubt
question about application-managed Entity manager