Hi all, i need to use EntityManagerFactory y EntityManager outside of an EJB,
in fact i need to use them inside of a simple Pojo. The below class is a simple
pojo that load a collection from the DB and return that collection in form of
StecItem[] array. Now when i run this code i get the following error:
java.sql.SQLException: You cannot set autocommit during a managed transaction!
at
org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.setJdbcAutoCommit(BaseWrapperManagedConnection.java:482)
....
....
.......
Any help will be appreciated.
public class CargaNomencladores {
public static SelectItem[] cargaNomenclador(String
nomencladorClassName)
{
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("jsfTest");
EntityManager em = emf.createEntityManager();
Query query = em.createQuery("select n from " +
nomencladorClassName + "n");
List tempNomencladorRl = query.getResultList();
int size = tempNomencladorRl.size();
SelectItem[] nomencladorSelectItem = new SelectItem[size];
for (int i=0; i<size;i++){
SelectItem si = new
SelectItem(tempNomencladorRl.get(i),tempNomencladorRl.get(i).getValor());
nomencladorSelectItem= si;
}
em.close();
emf.close();
return nomencladorSelectItem;
}
}
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4108688#4108688
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4108688
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user