All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.drus.jpa.unit.cdi.EntityManagerHolder Maven / Gradle / Ivy

There is a newer version: 0.5.0
Show newest version
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