1 Reply Latest reply on Nov 7, 2006 9:19 AM by Tor Egil Jacobsen

    JBossRollbackException

    Tor Egil Jacobsen Novice

      A strange situation!

      I have persisted an entity bean, but when I try to read (READ) the entity back with a query object given by the entity manager, a rollback exception is thrown...

      ...my questions: why? and what can I do to avoid this?

      The exception:

      org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=C6ZHZ0J/11, BranchQual=, localId=11] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.persistence.PersistenceException: org.hibernate.PropertyValueException: not-null property references a null or transient value: nu.hjemme.user.persistence.MenuItem.name)


      I have a entity called User which has the following relation:
       @IndexColumn(name = "menuItemsIndex")
       @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
       @JoinColumn(name = "userId")
       private List <MenuItem> menuItems = null;
      


      The property of the MenuItem which is not supposed to be null:
       @Column(length = 15, nullable = false)
       private String name = null;
      


      ... again: why is this happening? It seems like it is trying to committ something when I only want to read from the database.

      I try to read the database with an ejb query (EJBQL) but this exception is thrown before the query is compiled by hibernate.

      I am using jboss-4.0.5.GA.

      The exception is mentioning that it is not part of a transaction (status=STATUS_NO_TRANSACTION), but I would not think that this was necessary when reading. Another question regarding entity managers: It is stated that a entity manager has a transaction scope of the instantiating class. If you instantiate the entity manager in one class but use this instance with a sub class by invoking a method on the super class, will this affect the transaction scope?

        • 1. Re: JBossRollbackException
          Tor Egil Jacobsen Novice

          After a lot of searching I found a bug in one of my constructors which will cause my code to fail. It should not be used as the entity manager is not to use other constructors than a no argument one, but ....

          Because of the bug in the first place, I have never come around to bug test the rest of the code which would have revealed this failure.

          But there is still questions that I need to get answered:

          Why is the database trying to comitt something when I only want to read from the database?

          and

          It is stated that an entity manager has a transaction scope of the instantiating class. If you instantiate the entity manager in one class but use this instance with a sub class by invoking a method on the super class, will this affect the transaction scope?