java.lang.Objectorg.springframework.orm.ibatis.SqlMapClientFactoryBean
All Implemented Interfaces:
InitializingBean, FactoryBean
Either org.springframework.jdbc.datasource.DataSourceTransactionManager or org.springframework.transaction.jta.JtaTransactionManager can be used for transaction demarcation in combination with a SqlMapClient, with JTA only necessary for transactions which span multiple databases.
Allows for specifying a DataSource at the SqlMapClient level. This is preferable to per-DAO DataSource references, as it allows for lazy loading and avoids repeated DataSource references in every DAO.
Note: As of Spring 2.5.5, this class (finally) requires iBATIS 2.3 or higher. The new "mappingLocations" feature requires iBATIS 2.3.2.
Juergen - Hoeller24.02.2004 - | Constructor: |
|---|
|
| Method from org.springframework.orm.ibatis.SqlMapClientFactoryBean Summary: |
|---|
| afterPropertiesSet, applyTransactionConfig, buildSqlMapClient, getConfigTimeLobHandler, getObject, getObjectType, isSingleton, setConfigLocation, setConfigLocations, setDataSource, setLobHandler, setMappingLocations, setSqlMapClientProperties, setTransactionConfigClass, setTransactionConfigProperties, setUseTransactionAwareDataSource |
| Methods from java.lang.Object: |
|---|
| equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from org.springframework.orm.ibatis.SqlMapClientFactoryBean Detail: |
|---|
|
The default implementation casts to ExtendedSqlMapClient, retrieves the maximum number of concurrent transactions from the SqlMapExecutorDelegate, and sets an iBATIS TransactionManager with the given TransactionConfig. |
The default implementation uses the standard iBATIS SqlMapClientBuilder API to build a SqlMapClient instance based on an InputStream (if possible, on iBATIS 2.3 and higher) or on a Reader (on iBATIS up to version 2.2). |
This instance will be set before initialization of the corresponding SqlMapClient, and reset immediately afterwards. It is thus only available during configuration. |
|
|
|
|
|
If specified, this will override corresponding settings in the SqlMapClient properties. Usually, you will specify DataSource and transaction configuration either here or in SqlMapClient properties. Specifying a DataSource for the SqlMapClient rather than for each individual DAO allows for lazy loading, for example when using PaginatedList results. With a DataSource passed in here, you don't need to specify one for each DAO. Passing the SqlMapClient to the DAOs is enough, as it already carries a DataSource. Thus, it's recommended to specify the DataSource at this central location only. Thanks to Brandon Goodin from the iBATIS team for the hint on how to make this work with Spring's integration strategy! |
|
This is an alternative to specifying "<sqlMap>" entries in a sql-map-client config file. This property being based on Spring's resource abstraction also allows for specifying resource patterns here: e.g. "/myApp/*-map.xml". Note that this feature requires iBATIS 2.3.2; it will not work with any previous iBATIS version. |
<properties> tag in the sql-map-config.xml
file. Will be used to resolve placeholders in the config file. |
com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig.
Will only get applied when using a Spring-managed DataSource. An instance of this class will get populated with the given DataSource and initialized with the given properties. The default ExternalTransactionConfig is appropriate if there is external transaction management that the SqlMapClient should participate in: be it Spring transaction management, EJB CMT or plain JTA. This should be the typical scenario. If there is no active transaction, SqlMapClient operations will execute SQL statements non-transactionally. JdbcTransactionConfig or JtaTransactionConfig is only necessary when using the iBATIS SqlMapTransactionManager API instead of external transactions. If there is no explicit transaction, SqlMapClient operations will automatically start a transaction for their own scope (in contrast to the external transaction mode, see above). It is strongly recommended to use iBATIS SQL Maps with Spring transaction management (or EJB CMT). In this case, the default ExternalTransactionConfig is fine. Lazy loading and SQL Maps operations without explicit transaction demarcation will execute non-transactionally. Even with Spring transaction management, it might be desirable to specify JdbcTransactionConfig: This will still participate in existing Spring-managed transactions, but lazy loading and operations without explicit transaction demaration will execute in their own auto-started transactions. However, this is usually not necessary. |
|
Default is "true": When the SqlMapClient performs direct database operations outside of Spring's SqlMapClientTemplate (for example, lazy loading or direct SqlMapClient access), it will still participate in active Spring-managed transactions. As a further effect, using a transaction-aware DataSource will apply remaining transaction timeouts to all created JDBC Statements. This means that all operations performed by the SqlMapClient will automatically participate in Spring-managed transaction timeouts. Turn this flag off to get raw DataSource handling, without Spring transaction checks. Operations on Spring's SqlMapClientTemplate will still detect Spring-managed transactions, but lazy loading or direct SqlMapClient access won't. |