Instanciei EntityManager manager = new JPAUtil().getEntityManager(); na TesteJPA porém ele não reconhece e pede que eu crie uma classe JPAUtil
insira seu código aqui
package br.com.caelum.financas.teste;
import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence;
import br.com.caelum.financas.modelo.Conta;
public class TesteJPA {
public static void main(String[] args) {
double inicio = System.currentTimeMillis();
Conta conta = new Conta(); conta.setTitular("Lorran"); conta.setBanco("Itaú"); conta.setNumero("123456"); conta.setAgencia("325");
/* EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("financas");
EntityManager manager = entityManagerFactory.createEntityManager(); */
EntityManager manager = new JPAUtil().getEntityManager();
manager.getTransaction().begin();
manager.persist(conta);
manager.getTransaction().commit();
manager.close();
double fim = System.currentTimeMillis(); System.out.println("Executado em "+(fim - inicio)/1000+" s");
}
}
#package br.com.caelum.financas.util;
import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence;
public class JPAUtil {
private static EntityManagerFactory entityManagerFactory = Persistence .createEntityManagerFactory("financas");
public EntityManager getEntityManager() { return entityManagerFactory.createEntityManager(); } }