eu.drus.jpa.unit.cdi.EntityManagerHolder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jpa-unit-cdi Show documentation
Show all versions of jpa-unit-cdi Show documentation
Makes JPA Unit usable in CDI test environment
package eu.drus.jpa.unit.cdi;
import javax.persistence.EntityManager;
class EntityManagerHolder {
public static final EntityManagerHolder INSTANCE = new EntityManagerHolder();
private static final ThreadLocal CONTEXT = new ThreadLocal<>();
private EntityManagerHolder() {}
public EntityManager getEntityManager() {
return CONTEXT.get();
}
public void setEntityManager(final EntityManager value) {
if (value != null) {
CONTEXT.set(value);
} else {
CONTEXT.remove();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy