The Transaction Quickstart demonstrates Spring's transaction management features. The database schema are two simple tables, credit and debit, which contain an Identifier and an Amount. The quick start shows the use of declarative transactions using attributes and also the ability to change the transaction manager (local or distributed) via changes to only the configuration files - no code changes are required.
The design of the application is very simple and consists of two
logical layers, a business service layer in the namespace
Spring.TxQuickStart.Services and a DAO layer in the
namespace Spring.TxQuickStart.Dao. As this is just a
toy example the business service layer does nothing more than call two DAO
objects. The business service is to transfer money in a bank account and
is blatantly taken from the book Pro
ADO.NET by Sahil Malik. The transfer service is defined by the
interface IAccountManager with the
implementation AccountManager. The money is
'contained' in a credit table and debit table in the database. The Sql
Server schema for the tables is located in the file
CreditsDebitsSchema.sql. Transferring the money requires an ACID operation
on these two tables. The credit operation is defined via a
IAccountCreditDao interface and the debit
operation via an IAccountDebitDao
interface. Implementations based on AdoTemplate are
in the namespace Spring.TxQuickStart.Dao.Ado. Note that
Spring's transaction management framework allows mixing of data access
technologies within the same transaction, i.e. ORM and ADO.NET. A
demonstration of this features will be added to this quick start in a
future release.
The Manager and DAO interfaces are shown below
public interface IAccountManager
{
void DoTransfer(float creditAmount, float debitAmount);
}
public interface IAccountCreditDao
{
void CreateCredit(float creditAmount);
}
public interface IAccountDebitDao
{
void DebitAccount(float debitAmount);
}TO BE DONE...