Pascal Knüppel created OPENEJB-2122:
---------------------------------------

             Summary: New Transaction gets rolled back
                 Key: OPENEJB-2122
                 URL: https://issues.apache.org/jira/browse/OPENEJB-2122
             Project: OpenEJB
          Issue Type: Bug
         Environment: Java 8 update 51 64bit
Windows 7
            Reporter: Pascal Knüppel
            Priority: Critical


I am currently on a project where I need to rollback only part of my 
transaction. I tested my code on wildfly and it works perfectly. With openejb 
though all my transactions are rolled back and I am not able to find a 
workaround.

I have a really simple stateless bean which calls 2 methods. One method has 
attribute transaction required and the second has transaction requires new.

{code:title=MyTestRessource.java|borderStyle=solid}
@Stateless
@Path("test")
public class MyTestRessource {

    @Inject
    private MyTestBean myTestBean;

    @GET
    @Path("testMethod")
    @Transactional(Transactional.TxType.NOT_SUPPORTED)
    public String simpleTestMethod() {
        myTestBean.persistAnEntity();
        myTestBean.doOnFail();
        return "execution finished";
    }
}
{code}

{code:title=MyTestBean.java|borderStyle=solid}
@Stateless
@Path("test")
@RequestScoped
public class MyTestBean {

    @Inject
    @Named(EntityManagerProducer.oracleEntityManagerName)
    private EntityManager oracleEntityManager;

    @Resource
    private SessionContext sessionContext;

    @Transactional(Transactional.TxType.REQUIRED)
    public void persistAnEntity() {
        FRX_SECURITYVERSION frx_securityversion = new FRX_SECURITYVERSION(
                "SV0111", new Date()
        );
        oracleEntityManager.persist(frx_securityversion);
        sessionContext.setRollbackOnly();
    }

    @Transactional(Transactional.TxType.REQUIRES_NEW)
    public void doOnFail() {
        FRX_SECURITYVERSION frx_securityversion = new FRX_SECURITYVERSION(
                "SV0100", new Date(System.currentTimeMillis() + 1000L * 60 * 60 
* 24 * 365 * 999)
        );
        oracleEntityManager.persist(frx_securityversion);
    }
}
{code}

If I execute this code in wildfly I get no problems and the entry from the 
second method is persisted while the first is rolled back. With openejb both 
entries are rolled back. Is there anything I am missing?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to