2 Replies Latest reply on Feb 28, 2005 3:46 PM by littleant

    Transaction problem

    littleant

      Hi everybody !

      We are developping a J2EE application and we have big problems with the transactions.
      We are searching many documentations and every day we are learning lots of interesting things but... currently, we have decided to change the finders into the DAO for a performance reason (we are using another driver to connect to SQLServer2000 : JTDS1.0.2 --> excellent driver).

      But the problem is that if one creates or updates entities and then just after a query DAO is executed to get back the data whose state has just changed, we don't receive them.
      Correctly! Because the DAO is called inside of a session bean's method with trans-attribute "required". Thus the data is not yet committed.

      Unfortunately, i can't to provide you ejb-jar.xml, jboss.xml because the files of our application are in my workplace but i'm going to show an example :

      
      JournalDelegate
      
      
      public Collection determineValidJournals(String logonId) throws SystemException{
       try{
       return getSessionFacade().determinevalidJournals(logonId);
       } catch (RemoteException re) {
       throw new SystemException(.......);
       }
      }
      
      
      
      
      JournalSessionFacadeObject
       --> EJBObject
      
      public Collection determineValidJournals(String logonId) throws SystemException, RemoteException;
      
      
      
      
      JournalSessionFacade
       --> SessionBean
      
      public Collection determineValidJournals(String logonId) throws SystemException {
       return getSessionBean().determineValidJournals(logonId);
      }
      
      
      
      
      
      JournalSessionBeanObject
       --> EJBlocalObject
      
      public Collection determineValidJournals(String logonId) throws SystemException;
      
      
      
      
      JournalSessionBean
       --> SessionBean
      
      public Collection determineValidJournals(String logonId) throws SystemException {
       Iterator it = findAllFinancialCentersByVerifier(logonId);
       Collection coll = new ArrayList();
       while (it.hasNext()){
       FinancialCenterVO fc = (FinancialCenterVO) it.next();
       validateJournal(fc);
       coll.addAll(findValidJournals(fc));
      -->
       This last method causes a problem
      
      
       }
       return coll;
      }
      
      
      public void validateJournal(fc) throws SystemException{
       Iterator it = findCheckableJournals(fc);
       while (it.hasNext()){
       JournalVO journal = (JournalVO) it.next();
       update data into DB after check of datas validity by findByPrimaryKey(......).setValueOb
      ject(journal);
       }
      }
      
      




      ejb-jar.xml

      Only the local Session beans and Entity Beans methods are in "REQUIRED", NOT the session facades methods.



      To resolve the fastest way, we want to put the findValidJournals(.....) in determineValidJournals(....) of SessionFacade. But JBoss has decided to put this method into a transaction !!!


      In fact, that doesn't resolve our problem --> So that method has been put into JournalDelegate. But this is abnormal --> 2 network calls


      Why does JBoss automatically make a transaction ????

      Does a tag exist to modify this behavior ????


      Thank for your time :-)


      Pascale



        • 1. Re: Transaction problem
          stevenpeh

          why don't you just configure the methods in your session facade to have the tx attribute to be Never or NotSupported ? i.e.

           <container-transaction>
           <method>
           <ejb-name>mySessionFacade</ejb-name>
           <method-name>*</method-name>
           </method>
           <trans-attribute>Never</trans-attribute>
           </container-transaction>
          




          • 2. Re: Transaction problem
            littleant

            Many thanks stevenpeh!

            I actually found out how easy the answer was in the meantime.

            Of course : SessionFacade is just a class name (for a design pattern) for some session bean and since we define that particular bean as being "container managed", a transaction is automatically created for each call unless we define it to be different like in your excerpt.


            Bravo for your insight