users@glassfish.java.net

EJB CMT TransactionAttributeType.REQUIRES_NEW doesn't work.

From: <glassfish_at_javadesktop.org>
Date: Mon, 26 Jul 2010 06:26:40 PDT

GF v3 is under test.

@Stateless
    public class MySLSB {
        
            @Resource
            SessionContext ctx;
            @PersistenceContext(unitName = "myPU")
            EntityManager em;
            
            public void T1() {
                em.persist(new MyEntity(1L)); //T1 created!
                T2();
                ctx.setRollbackOnly();
            }
        
            @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
            public void T2() {
                em.persist(new MyEntity(2L)); //T2 created!
            }
        }

The client calls T1(), at first T2 as a new Transaction should be committed,
but T1 will be rolled back.

Expected result:
T1: insert into myentity set id=1;
T2: insert into myentity set id=2;
T2: commit;
T1: rollback;
-> The row with id=2 is created in DB.

Actual result:
insert into myentity set id=1;
insert into myentity set id=2;
rollback;
-> Nothing is created in DB.

What's the problem? Thanks a lot!
[Message sent by forum member 'glassfisher']

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