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

com.github.panchitoboy.common.ecb.EntityManagerProducer Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
package com.github.panchitoboy.common.ecb;

import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;

public class EntityManagerProducer {

    @PersistenceUnit
    private EntityManagerFactory emf;

    @Produces
    public EntityManager create() {
        return emf.createEntityManager();
    }

    public void close(@Disposes EntityManager em) {
        if (em.isOpen()) {
            em.close();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy