2 Replies Latest reply on Mar 3, 2015 9:30 AM by aslak

    No transaction

    nickarls

      I'm testing persistence and I'm seeing some strange behavior:

       

      I inject a stateful bean into the test and call it's methods but no insert statements are being generated. Tried adding the arquillian @Transactional annotation but that didn't help. If I add em.flush() after the merge I get a "no transaction in progress" (which is consistent with the fact that no merge is being performed). If i outside the test trying starting a UserTransaction and using em.joinTransaction, I get a "transaction already active". Really strange. I'm using a WF 9.

        • 1. Re: No transaction
          nickarls

          Getting even more strange.

           

          If I have an entity Foo and a FooBean with a setFoo(Foo) and saveFoo() which does a merge on the foo, I get update statements for a sequence like

           

          Foo foo = em.find(Foo.class, 1);

          fooBean.setFoo(foo);

          fooBean.saveFoo();

           

          but not for

           

          Foo foo = new Foo();

          fooBean.setFoo(foo);

          fooBean.saveFoo();

           

          Both use an requestscoped, produced CDI-@Injected EM

          ...

          • 2. Re: No transaction
            aslak

            To follow up conversation from IRC;

             

            The basics seems to work: https://gist.github.com/aslakknutsen/cdde48b1c735a01ae307

             

            Did you come and closer to figuring out what the cause of this behavior is?