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

br.com.andrewribeiro.ribrest.services.orm.EMFFactory Maven / Gradle / Ivy

Go to download

Ribrest Framework - A simple Java framework that truly improve your productivity when developing restful based webservices.

There is a newer version: 1.27.0
Show newest version
package br.com.andrewribeiro.ribrest.services.orm;

import javax.inject.Inject;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.glassfish.hk2.api.Factory;

/**
 *
 * @author Andrew Ribeiro
 */
public class EMFFactory implements Factory{
    
    private EntityManagerFactory emf;
    
    @Inject
    PersistenceUnitWrapper puw;
    

    @Override
    public EntityManagerFactory provide() {
        emf = emf != null ? emf : Persistence.createEntityManagerFactory(puw.getPersistenceUnitName());
        return emf;
    }

    @Override
    public void dispose(EntityManagerFactory t) {
        emf.close();
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy