estou importando um arquivo csv mas ele aparece o erro abaixo.
java.lang.IllegalStateException: Transaction already active
at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:56)
at com.dao.Pln0048rJpaDAO.merge(Pln0048rJpaDAO.java:72)
at com.principal.Monitoramento.csv(Monitoramento.java:177)
at com.principal.Monitoramento$1.run(Monitoramento.java:78)
java.lang.IllegalStateException: Transaction already active
at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:56)
at com.dao.Pln0048rJpaDAO.merge(Pln0048rJpaDAO.java:72)
at com.principal.Monitoramento.csv(Monitoramento.java:177)
at com.principal.Monitoramento$1.run(Monitoramento.java:78)
javax.persistence.RollbackException: Error while committing the transaction
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:92)
at com.dao.Pln0048rJpaDAO.merge(Pln0048rJpaDAO.java:74)
at com.principal.Monitoramento.csv(Monitoramento.java:177)
at com.principal.Monitoramento$1.run(Monitoramento.java:78)
Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: Flush during cascade is dangerous
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:80)
… 3 more
Caused by: org.hibernate.HibernateException: Flush during cascade is dangerous
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1191)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:404)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:75)
… 3 more
javax.persistence.RollbackException: Error while committing the transaction
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:92)
at com.dao.Pln0048rJpaDAO.merge(Pln0048rJpaDAO.java:74)
at com.principal.Monitoramento.csv(Monitoramento.java:177)
at com.principal.Monitoramento$1.run(Monitoramento.java:78)
Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: Flush during cascade is dangerous
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:80)
… 3 more
Caused by: org.hibernate.HibernateException: Flush during cascade is dangerous
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1191)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:404)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:75)
… 3 more
java.lang.IllegalStateException: Transaction not active
at org.hibernate.ejb.TransactionImpl.rollback(TransactionImpl.java:103)
at com.dao.Pln0048rJpaDAO.merge(Pln0048rJpaDAO.java:77)
at com.principal.Monitoramento.csv(Monitoramento.java:177)
at com.principal.Monitoramento$1.run(Monitoramento.java:78)
javax.persistence.RollbackException: Error while committing the transaction
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:92)
at com.dao.Pln0048rJpaDAO.merge(Pln0048rJpaDAO.java:74)
at com.principal.Monitoramento.csv(Monitoramento.java:177)
at com.principal.Monitoramento$1.run(Monitoramento.java:78)
Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: Flush during cascade is dangerous
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:80)
… 3 more
Caused by: org.hibernate.HibernateException: Flush during cascade is dangerous
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1191)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:404)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:75)
… 3 more
java.lang.IllegalStateException: Transaction not active
at org.hibernate.ejb.TransactionImpl.rollback(TransactionImpl.java:103)
at com.dao.Pln0048rJpaDAO.merge(Pln0048rJpaDAO.java:77)
at com.principal.Monitoramento.csv(Monitoramento.java:177)
at com.principal.Monitoramento$1.run(Monitoramento.java:78)
segue classe DAO
public void merge(Pln0048r pln0048r) {
try {
entityManager.getTransaction().begin();
entityManager.merge(pln0048r);
entityManager.getTransaction().commit();
} catch (Exception ex) {
ex.printStackTrace();
entityManager.getTransaction().rollback();
}
}
o erro na classe DAO é na linha "entityManager.getTransaction().begin();"
consegue me ajudar?