Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB3 in Action errata for EntityManager.refresh() method

 
Tyronne Fernando
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 4511
271
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Tyronne Fernando
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic