Open
Description
A very common pattern is to use an EntityManager which is @RequestScoped
with CDI. This is often referred to as the entitymanager-per-request pattern.
Currently I am unable to make this work in coordination with @Transactional
without going SynchronizationType.UNSYNCHRONIZED
and manually calling an entityManager.joinTransaction()
public class PersistenceResources {
@PersistenceContext(type = PersistenceContextType.EXTENDED, synchronization = SynchronizationType.SYNCHRONIZED)
private EntityManager em;
@Produces
@RequestScoped
private EntityManager requestScopedEntityManager() {
return em;
}
}
Unfortunately all the entities appear to get detached after the first transaction commits. Is this pattern possible with EE 7 without having to manually join to the transaction?
Metadata
Metadata
Assignees
Labels
No labels