Java Reference
In-Depth Information
Table 3.4
Built-in transaction managers
Name
Description
JDBC
Used to provide simple JDBC-based transaction management. For most cases, this
is all you need.
JTA
Used to provide container-based transaction management in your application.
EXTERNAL
Used to provide no transaction management, and assumes that the application will
manage the transactions instead of iBATIS.
You may recognize the names of those transaction managers from the
previous table. They are simply type aliases for the fully qualified names
of the classes that implement them. This is a common pattern in the i BA-
TIS configuration files.
NOTE
Another setting that is available for the transaction manager is the commitRe-
quired attribute. This can be set to either true or false , and the default value is
false . This attribute is primarily used in situations where a commit or rollback is
required before a connection can be released.
For some operations (like selects and stored procedure calls) transactions are
not normally required, and are generally ignored. Some drivers (like the Sybase
driver, for instance) will not release a connection until any transactions that were
started for that connection are either committed or rolled back. In those cases,
the commitRequired attribute can be used to force that to happen even if nothing
has happened that would normally require a transaction.
The <property> elements
Each transaction manager can have different configuration options. Because of
that, the i BATIS framework uses the <property> element to allow you to specify
any number of named values that can be supplied to the transaction manager
implementation.
The <dataSource> element
In Java, the standard method for working with a connection pool is by using a
javax.sql.DataSource object. The <dataSource> element of the transaction man-
ager has a type attribute that tells i BATIS what class to instantiate and use for its
data source factory. The name of this element is a bit misleading, because it does
not really define a DataSource , but a DataSourceFactory implementation, which
will be used to create the actual DataSource .
Search WWH ::




Custom Search