I understand that an extended persistence context lasts the duration of the conversation or until the persistence context is closed by the container when the @Remove method of the stateful session bean completes (or the stateful session bean instance is otherwise destroyed).
Now obviously, the persistence context will also be closed in JPA 2/Hibernate when the bean is destroyed, but is there a corollary to @Remove in JPA 2/Hibernate?
Also, are there any pitfalls to keep in mind while using an extended persistence context?
JPA/Hibernate are persistence technologies. They do not handle session (entity manager) management. They provide the entity manager and let other technologies manage it.
PersistenceContextType.EXTENDEDshould be handled by the framework which injects theEntityManagerwhere@PersistenceContextis present. This can’t be JPA/Hibernate alone.