0 Replies Latest reply on Sep 9, 2016 2:50 PM by 9967e232-2bf5-4dff-a451-206e772b9348

    Tomcat 7 - Setting UnitOfWork Properties to be used across DAOs

    9967e232-2bf5-4dff-a451-206e772b9348

      In Spring, is there a way I can access the properties of the unitofwork across the DAO's?

      Let's assume I have a service layer:

       

      public Class A { 

          impl.setUnitOfWork(details); 

          daoA.saveA(dto.getEntityADetails()) 

          daoB.saveB(dto.getEntityBDetails()); 

       

      pubcli class Impl extends TopLinkDaoSupport { 

          public void setUnitOfWork (TxnDetailsDTO details) { 

              getSection().getTopLinkTemplate().execute (new UnitOfWorkCallback() { 

                  protected object doInUnitOfWork (UnitofWork uow) { 

                      uow.setProperty ('prop1', details); 

                      return null; 

                  } 

               }); 

           } 

       

      public Class DAOA { 

           public saveA (DTO dto) { 

                        getSection().getTopLinkTemplate().execute (new UnitOfWorkCallback() { 

                                protected object doInUnitOfWork (UnitofWork uow) { 

                                       if (uow.getProperty('prop1')) 

                                          uow.registerObject(dto); 

                                      return null; 

                           } 

                 }); 

           } 

       

      public Class DAOB { 

        public saveB (DTO dto) { 

                  getSection().getTopLinkTemplate().execute (new UnitOfWorkCallback() { 

                           protected object doInUnitOfWork (UnitofWork uow) { 

                                if (uow.getProperty('prop1')) 

                                     uow.registerObject(dto); 

                                 return null; 

                          } 

                 }); 

           } 

       

      I understand that the setProperty() of uow is inherited from the session.

       

      How can I make sure that all the uow's I access in the callback share the same session in Tomcat with Spring? I am having the session instance as FinalizedClientSession when i listen to the uow.