5 Replies Latest reply on Apr 10, 2008 10:30 AM by nickarls

    Fresh transaction for POJO ResourceLoader?

    nickarls

      I have a custom org.jboss.seam.core.resourceLoader that fetches resources from the database.


      The problem is that I need keys for logging even when there has been a database error and the transaction is not active, I've tried various @Transactional annotation on my POJO but no go.


      What would be the correct way?

        • 1. Re: Fresh transaction for POJO ResourceLoader?
          nickarls

          EJB:s have some sort of TransactionAttributeType.REQUIRES_NEW but is there something like that for POJOs?

          • 2. Re: Fresh transaction for POJO ResourceLoader?
            nickarls

            Doing some magic with the user transaction?


            Doing some magic with the seam conversation?


            Waving a dead chicken across the keyboard?

            • 3. Re: Fresh transaction for POJO ResourceLoader?
              nickarls

              OK, I'll borrow my dogs rubber chicken for monday if I dont' get any other suggestions ...

              • 4. Re: Fresh transaction for POJO ResourceLoader?
                pmuir

                Nicklas Karlsson wrote on Mar 26, 2008 10:39 AM:


                EJB:s have some sort of TransactionAttributeType.REQUIRES_NEW but is there something like that for POJOs?


                Not AFAIK


                /**
                 * Transaction propagation strategies for Seam JavaBean 
                 * components. Note that unlike EJB3 components, there 
                 * are no strategies for suspending transactions.
                 * 
                 * @author Gavin King
                 *
                 */



                Which implies to me that you can't force a new transaction.


                Apart from managing the transaction yourself (which isn't nice), I can't see an easy solution. Perhaps your ResourceLoader has to detect that the Transaction is dead and uses a property file at this point (transaction death is fairly extreme...)

                • 5. Re: Fresh transaction for POJO ResourceLoader?
                  nickarls

                  Run into a side-plot when trying to make a custom log4j database appender: if there is a database error that kills the transaction and I try to log it by getting a connection from the same data source, I get a Transaction not active on the getConnection()


                  Since the "transaction infestation" seems to span across connections(?), is there any way to get around this other than have a separate logging-datasource?