2 Replies Latest reply on Mar 16, 2006 4:44 AM by roberto72

    Delayed insert

      Hi,

      I have a small test-code (on JBOSS 4.0.4RC1) which execute this actions:

      1) create an ABean (persistenced on DB)
      2) create an BBean (whith an idA() prop) (persistenced on DB)
      3) create an CBean (whith an idA() and idB() props) (persistenced on DB)
      4) I excute an ABean.getBBeans() on the bean created in step (1)
      [this select, via CBean, all BBeans indirectly linked to ABean]

      In step 4 I obtain a "null" set. Analizing log I have noted that the
      ABean.getBBeans() EJB3-generated query is executed BEFORE
      the three INSERT! :(

      How is this possibile? Can JBoss delay an insert AFTER a query which
      retrieve the inserted beans?

      TIA
      Roberto Colmegna

        • 1. Re: Delayed insert
          raist_majere

          If the creation operations have no transaction Requires New attribute, then the transaction in which you do the three creates and the final select are in the same transaction, so there has been no commit after the three created beans and so the select returns null.

          • 2. Re: Delayed insert

            Thanks for your reply.

            I putted this line:
            @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)

            before stateless-session-bean method which execute
            the INSERTs/SELECT. But after running code I have
            obtained the same result. :(