java.lang.IllegalStateException: Transaction not active

Hibernate JIRA | Meinolf | 1 decade ago
  1. 0

    Hi gurus, I just played a little bit arround with the Hibernate Entity Manager and found a bug which is nearly similar to a already closed bug: http://opensource.atlassian.com/projects/hibernate/browse/EJB-221 I've done an updated of all jar files of the "fix version/s 3.2.0.cr3 but this didn't help. I'm using EntityManager and reading by id a Project object out of the database which has a number of oneToMany references within. All references are declared as Fetch.LAZY but using hibernates EntityManager does this not take into account. When committing the transaction I get an Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.arvato.hibernate.entities.Tras001.tras070 -> com.arvato.hibernate.entities.Tras070 without saving anything, I do just a simple read?! So we've two errors here, 1. Why are Fetch.LAZY things read by default (Affected: EntityManager with annotation configuration and xml configuration as well) 2. TransientObjectException (Affected: EntityManager with annotation configuration. XML configuration does not throw this but does a read of lazy objects) I'll attach the Domain Object and the test class to make some things more clear to you. Cheers Meinolf P.S: There is another bug I found a few days ago regarding a wrong binding order of parameters. Can you please take a look at http://forum.hibernate.org/viewtopic.php?t=965575 This happens only when using annotation configuration. (Affected: Session and EntityManager) Here's the full stack trace: javax.persistence.RollbackException: Error while commiting the transaction at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:63) at com.arvato.hibernate.entities.test.HibernateEntityManagerTest.load(HibernateEntityManagerTest.java:71) at com.arvato.hibernate.entities.test.HibernateEntityManagerTest.main(HibernateEntityManagerTest.java:31) Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.arvato.hibernate.entities.Tras001.tras070 -> com.arvato.hibernate.entities.Tras070 at org.hibernate.engine.CascadingAction$9.noCascade(CascadingAction.java:350) at org.hibernate.engine.Cascade.cascade(Cascade.java:139) at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:130) at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:121) at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106) at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:53) ... 2 more Exception in thread "main" java.lang.IllegalStateException: Transaction not active at org.hibernate.ejb.TransactionImpl.rollback(TransactionImpl.java:74) at com.arvato.hibernate.entities.test.HibernateEntityManagerTest.load(HibernateEntityManagerTest.java:77) at com.arvato.hibernate.entities.test.HibernateEntityManagerTest.main(HibernateEntityManagerTest.java:31)

    Hibernate JIRA | 1 decade ago | Meinolf
    java.lang.IllegalStateException: Transaction not active
  2. 0

    Hi gurus, I just played a little bit arround with the Hibernate Entity Manager and found a bug which is nearly similar to a already closed bug: http://opensource.atlassian.com/projects/hibernate/browse/EJB-221 I've done an updated of all jar files of the "fix version/s 3.2.0.cr3 but this didn't help. I'm using EntityManager and reading by id a Project object out of the database which has a number of oneToMany references within. All references are declared as Fetch.LAZY but using hibernates EntityManager does this not take into account. When committing the transaction I get an Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.arvato.hibernate.entities.Tras001.tras070 -> com.arvato.hibernate.entities.Tras070 without saving anything, I do just a simple read?! So we've two errors here, 1. Why are Fetch.LAZY things read by default (Affected: EntityManager with annotation configuration and xml configuration as well) 2. TransientObjectException (Affected: EntityManager with annotation configuration. XML configuration does not throw this but does a read of lazy objects) I'll attach the Domain Object and the test class to make some things more clear to you. Cheers Meinolf P.S: There is another bug I found a few days ago regarding a wrong binding order of parameters. Can you please take a look at http://forum.hibernate.org/viewtopic.php?t=965575 This happens only when using annotation configuration. (Affected: Session and EntityManager) Here's the full stack trace: javax.persistence.RollbackException: Error while commiting the transaction at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:63) at com.arvato.hibernate.entities.test.HibernateEntityManagerTest.load(HibernateEntityManagerTest.java:71) at com.arvato.hibernate.entities.test.HibernateEntityManagerTest.main(HibernateEntityManagerTest.java:31) Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.arvato.hibernate.entities.Tras001.tras070 -> com.arvato.hibernate.entities.Tras070 at org.hibernate.engine.CascadingAction$9.noCascade(CascadingAction.java:350) at org.hibernate.engine.Cascade.cascade(Cascade.java:139) at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:130) at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:121) at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106) at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:53) ... 2 more Exception in thread "main" java.lang.IllegalStateException: Transaction not active at org.hibernate.ejb.TransactionImpl.rollback(TransactionImpl.java:74) at com.arvato.hibernate.entities.test.HibernateEntityManagerTest.load(HibernateEntityManagerTest.java:77) at com.arvato.hibernate.entities.test.HibernateEntityManagerTest.main(HibernateEntityManagerTest.java:31)

    Hibernate JIRA | 1 decade ago | Meinolf
    java.lang.IllegalStateException: Transaction not active
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    GitHub comment 43#6866220

    GitHub | 4 years ago | wakaleo
    java.lang.IllegalStateException: Transaction not active
  5. 0

    JPA Hibernate Exception

    Stack Overflow | 4 years ago | user1566552
    java.lang.IllegalStateException: Transaction not active

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Transaction not active

      at org.hibernate.ejb.TransactionImpl.rollback()
    2. Hibernate EJB
      TransactionImpl.rollback
      1. org.hibernate.ejb.TransactionImpl.rollback(TransactionImpl.java:74)
      1 frame
    3. com.arvato.hibernate
      HibernateEntityManagerTest.main
      1. com.arvato.hibernate.entities.test.HibernateEntityManagerTest.load(HibernateEntityManagerTest.java:77)
      2. com.arvato.hibernate.entities.test.HibernateEntityManagerTest.main(HibernateEntityManagerTest.java:31)
      2 frames