A way to detach a specific JPA Entity Bean :
What is the main problem here ?
EntityManager.flush () method persists all changes from attached JPA Entity Beans that was acquired through an EntityManager to the underyling database.
But for some reason we don't want to change some specific objects within the current PersistenceContext.
So What we can do to prevent this situation ?
Answer :
EntityManager.refresh(Object o)
This method will restore original state of the entity, if primary key of the entity bean has not been changed.
No comments:
Post a Comment