E ai galera…
To com um problema, estou criando uma classe de entidade JPA para um projeto q usa JSF. Troquei minha versao do netbeans para 7.0 e ao criar a Classe Jpa ela esta gerando diferente de antes, no construtor é necessário passar um objeto UserTransaction, porem nao faço a minina ideia para que seja isso:
[code]
public class PaisJpaController implements Serializable {
public PaisJpaController(UserTransaction utx, EntityManagerFactory emf) {
this.utx = utx;
this.emf = emf;
}
private UserTransaction utx = null;
private EntityManagerFactory emf = null;
public EntityManager getEntityManager() {
return emf.createEntityManager();
}
public void create(Pais pais) throws RollbackFailureException, Exception {
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
em.persist(pais);
utx.commit();
} catch (Exception ex) {
try {
utx.rollback();
} catch (Exception re) {
throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}[/code]
e antes me gerava assim:
[code]
public CidadeJpaController() {
emf = Persistence.createEntityManagerFactory(“f2erpPU”);
}
private EntityManagerFactory emf = null;
public EntityManager getEntityManager() {
return emf.createEntityManager();
}
public void create(Cidade cidade) {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
em.persist(cidade);
em.getTransaction().commit();
} finally {
if (em != null) {
em.close();
}
}
}[/code]
Alguem sabe como lidar com esse modelo novo?