package UhuRisk;


import java.util.List;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;

/**
 *
 * @author SR.LOPEZ
 */
public class ControladorBD {
    
    private static EntityManagerFactory emf = javax.persistence.Persistence.createEntityManagerFactory("Java-UhuRiskPU");
    /**
    * Creates a new instance of ControladorBD
    */
    private  ControladorBD() {
    }

    public static void persist(Object object) {
        
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        try {
            em.merge(object);
            em.getTransaction().commit();
        } catch (Exception e) {
            e.printStackTrace();
            em.getTransaction().rollback();
        } finally {
            em.close();
        }
    }
   
    public static List getData() {
      return emf.createEntityManager().createQuery("SELECT p FROM Partida p").getResultList();
}

}
