Detach an entity from JPA/EJB3 persistence context

(may be too late to answer, but can be useful for others)

I’m developing my first system with JPA right now. Unfortunately I’m faced with this problem when this system is almost complete.

Simply put. Use Hibernate, or wait for JPA 2.0.

In Hibernate, you can use ‘session.evict(object)’ to remove one object from session. In JPA 2.0, in draft right now, there is the ‘EntityManager.detach(object)’ method to detach one object from persistence context.

Leave a Comment