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 ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 ?
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.