Entitymanager的问题,急!!!!
大致代码如下:
EntityManagerFactory emf = Persistence.createEntityManagerFactory( ".... ");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
em.persist(user);//user是一个实体bean
em.getTransaction().commit();
运行后,后台服务器提示:
15:19:55,406 ERROR [JDBCTransaction] JDBC commit failed
java.sql.SQLException: You cannot commit during a managed transaction!
at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManage dConnection.java:543)
.....
------解决方案--------------------帮你顶
------解决方案--------------------你把事务设置成自动的试试