users@glassfish.java.net

TopLink: EntityManager.getTransaction() rolls back the transaction

From: <glassfish_at_javadesktop.org>
Date: Sat, 19 Jan 2008 02:02:39 PST

Hi,

   I am using EntityManager#getTransaction() to find out if I am within a JTA context or not. The javadoc states that it should throw an IllegalStateException if not within JTA. The problem I have is the fact that it rollsback the JTA transaction in this case, which makes it useless for me to use... . Here is the offending code:

[code]
    public javax.persistence.EntityTransaction getTransaction(){
        try {
            return ((TransactionWrapper)transaction).getTransaction();
        } catch (RuntimeException e) {
            this.transaction.setRollbackOnlyInternal();
            throw e;
        }
    }
[/code]

Does it make sense to you?
[Message sent by forum member 'kimchy' (kimchy)]

http://forums.java.net/jive/thread.jspa?messageID=254840