Menu

How to run a transaction ?

Help
2004-11-29
2013-04-11
  • John Zoetebier

    John Zoetebier - 2004-11-29

    I wonder how to run a transaction with Butler.
    Class DatabaseBroker has these methods:
        public void initRequest()
        {
        }

        public void completeRequest(boolean success)
            throws SQLException
        {
        }

    An implementation like DefaultDabaseBroker should implement these methods.
    However the problem is that DefaultDabaseBroker is passed to setInstance of DatabaseBroker.
    It would be a real hazzle to create a new instance of DefaultDatabaseBroker and call method setInstance for each transaction.

    Is there a better way in Butler ?

     
    • Fredrik Bertilsson

      TransactionManager tm =
      DatabaseBroker.getInstance().getTransactionManager();
      tm.begin();
      // Do stuff
      tm.end();

      If you are using an 3-tier solution, you should using TransactionInterceptor, that will do this stuff.

       

Log in to post a comment.

MongoDB Logo MongoDB