Class SqlMapClientFactoryBean

java.lang.Object
org.springframework.orm.ibatis.SqlMapClientFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean<com.ibatis.sqlmap.client.SqlMapClient>, org.springframework.beans.factory.InitializingBean

@Deprecated public class SqlMapClientFactoryBean extends Object implements org.springframework.beans.factory.FactoryBean<com.ibatis.sqlmap.client.SqlMapClient>, org.springframework.beans.factory.InitializingBean
Deprecated.
as of Spring 3.2, in favor of the native Spring support in the Mybatis follow-up project (https://mybatis.org/)
FactoryBean that creates an iBATIS SqlMapClient. This is the usual way to set up a shared iBATIS SqlMapClient in a Spring application context; the SqlMapClient can then be passed to iBATIS-based DAOs via dependency injection.

Either DataSourceTransactionManager or 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.

Since:
24.02.2004
Author:
Juergen Hoeller
See Also:
  • Field Summary

    Fields inherited from interface org.springframework.beans.factory.FactoryBean

    OBJECT_TYPE_ATTRIBUTE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deprecated.
     
    protected void
    applyTransactionConfig(com.ibatis.sqlmap.client.SqlMapClient sqlMapClient, com.ibatis.sqlmap.engine.transaction.TransactionConfig transactionConfig)
    Deprecated.
    Apply the given iBATIS TransactionConfig to the SqlMapClient.
    protected com.ibatis.sqlmap.client.SqlMapClient
    buildSqlMapClient(org.springframework.core.io.Resource[] configLocations, org.springframework.core.io.Resource[] mappingLocations, Properties properties)
    Deprecated.
    Build a SqlMapClient instance based on the given standard configuration.
    static org.springframework.jdbc.support.lob.LobHandler
    Deprecated.
    Return the LobHandler for the currently configured iBATIS SqlMapClient, to be used by TypeHandler implementations like ClobStringTypeHandler.
    com.ibatis.sqlmap.client.SqlMapClient
    Deprecated.
     
    Class<? extends com.ibatis.sqlmap.client.SqlMapClient>
    Deprecated.
     
    boolean
    Deprecated.
     
    void
    setConfigLocation(org.springframework.core.io.Resource configLocation)
    Deprecated.
    Set the location of the iBATIS SqlMapClient config file.
    void
    setConfigLocations(org.springframework.core.io.Resource[] configLocations)
    Deprecated.
    Set multiple locations of iBATIS SqlMapClient config files that are going to be merged into one unified configuration at runtime.
    void
    Deprecated.
    Set the DataSource to be used by iBATIS SQL Maps.
    void
    setLobHandler(org.springframework.jdbc.support.lob.LobHandler lobHandler)
    Deprecated.
    Set the LobHandler to be used by the SqlMapClient.
    void
    setMappingLocations(org.springframework.core.io.Resource[] mappingLocations)
    Deprecated.
    Set locations of iBATIS sql-map mapping files that are going to be merged into the SqlMapClient configuration at runtime.
    void
    setSqlMapClientProperties(Properties sqlMapClientProperties)
    Deprecated.
    Set optional properties to be passed into the SqlMapClientBuilder, as alternative to a &lt;properties&gt; tag in the sql-map-config.xml file.
    void
    setTransactionConfigClass(Class<? extends com.ibatis.sqlmap.engine.transaction.TransactionConfig> transactionConfigClass)
    Deprecated.
    Set the iBATIS TransactionConfig class to use.
    void
    setTransactionConfigProperties(Properties transactionConfigProperties)
    Deprecated.
    Set properties to be passed to the TransactionConfig instance used by this SqlMapClient.
    void
    setUseTransactionAwareDataSource(boolean useTransactionAwareDataSource)
    Deprecated.
    Set whether to use a transaction-aware DataSource for the SqlMapClient, i.e. whether to automatically wrap the passed-in DataSource with Spring's TransactionAwareDataSourceProxy.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SqlMapClientFactoryBean

      public SqlMapClientFactoryBean()
      Deprecated.
  • Method Details

    • getConfigTimeLobHandler

      public static org.springframework.jdbc.support.lob.LobHandler getConfigTimeLobHandler()
      Deprecated.
      Return the LobHandler for the currently configured iBATIS SqlMapClient, to be used by TypeHandler implementations like ClobStringTypeHandler.

      This instance will be set before initialization of the corresponding SqlMapClient, and reset immediately afterwards. It is thus only available during configuration.

      See Also:
    • setConfigLocation

      public void setConfigLocation(org.springframework.core.io.Resource configLocation)
      Deprecated.
      Set the location of the iBATIS SqlMapClient config file. A typical value is "WEB-INF/sql-map-config.xml".
      See Also:
    • setConfigLocations

      public void setConfigLocations(org.springframework.core.io.Resource[] configLocations)
      Deprecated.
      Set multiple locations of iBATIS SqlMapClient config files that are going to be merged into one unified configuration at runtime.
      Parameters:
      configLocations - the config locations
    • setMappingLocations

      public void setMappingLocations(org.springframework.core.io.Resource[] mappingLocations)
      Deprecated.
      Set locations of iBATIS sql-map mapping files that are going to be merged into the SqlMapClient configuration at runtime.

      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.

      Parameters:
      mappingLocations - the mapping locations
    • setSqlMapClientProperties

      public void setSqlMapClientProperties(Properties sqlMapClientProperties)
      Deprecated.
      Set optional properties to be passed into the SqlMapClientBuilder, as alternative to a &lt;properties&gt; tag in the sql-map-config.xml file. Will be used to resolve placeholders in the config file.
      Parameters:
      sqlMapClientProperties - the client properties
      See Also:
    • setDataSource

      public void setDataSource(DataSource dataSource)
      Deprecated.
      Set the DataSource to be used by iBATIS SQL Maps. This will be passed to the SqlMapClient as part of a TransactionConfig instance.

      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!

      Parameters:
      dataSource - the data source
      See Also:
    • setUseTransactionAwareDataSource

      public void setUseTransactionAwareDataSource(boolean useTransactionAwareDataSource)
      Deprecated.
      Set whether to use a transaction-aware DataSource for the SqlMapClient, i.e. whether to automatically wrap the passed-in DataSource with Spring's TransactionAwareDataSourceProxy.

      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.

      Parameters:
      useTransactionAwareDataSource - whether to use transaction aware datasource
      See Also:
    • setTransactionConfigClass

      public void setTransactionConfigClass(Class<? extends com.ibatis.sqlmap.engine.transaction.TransactionConfig> transactionConfigClass)
      Deprecated.
      Set the iBATIS TransactionConfig class to use. Default is 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 JakartaTransactionConfig/JavaxTransactionConfig 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.

      Parameters:
      transactionConfigClass - the transaction config class
      See Also:
    • setTransactionConfigProperties

      public void setTransactionConfigProperties(Properties transactionConfigProperties)
      Deprecated.
      Set properties to be passed to the TransactionConfig instance used by this SqlMapClient. Supported properties depend on the concrete TransactionConfig implementation used:

      • ExternalTransactionConfig supports "DefaultAutoCommit" (default: false) and "SetAutoCommitAllowed" (default: true). Note that Spring uses SetAutoCommitAllowed = false as default, in contrast to the iBATIS default, to always keep the original autoCommit value as provided by the connection pool.
      • JdbcTransactionConfig does not supported any properties.
      • JakartaTransactionConfig (jakarta namespace) and JavaxTransactionConfig (javax namespace) both support "UserTransaction" (no default), specifying the JNDI location of the JTA UserTransaction (usually "java:comp/UserTransaction").
      Parameters:
      transactionConfigProperties - the transaction config properties
      See Also:
      • TransactionConfig.initialize(Properties)
      • ExternalTransactionConfig
      • JdbcTransactionConfig
      • JakartaTransactionConfig
      • JavaxTransactionConfig
    • setLobHandler

      public void setLobHandler(org.springframework.jdbc.support.lob.LobHandler lobHandler)
      Deprecated.
      Set the LobHandler to be used by the SqlMapClient. Will be exposed at config time for TypeHandler implementations.
      Parameters:
      lobHandler - the lob handler
      See Also:
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Deprecated.
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • buildSqlMapClient

      protected com.ibatis.sqlmap.client.SqlMapClient buildSqlMapClient(org.springframework.core.io.Resource[] configLocations, org.springframework.core.io.Resource[] mappingLocations, Properties properties) throws IOException
      Deprecated.
      Build a SqlMapClient instance based on the given standard configuration.

      The default implementation uses the standard iBATIS SqlMapClientBuilder API to build a SqlMapClient instance based on an InputStream.

      Parameters:
      configLocations - the config files to load from
      mappingLocations - the mapping files to load from
      properties - the SqlMapClient properties (if any)
      Returns:
      the SqlMapClient instance (never null)
      Throws:
      IOException - if loading the config file failed
      See Also:
      • SqlMapClientBuilder.buildSqlMapClient(Reader)
    • applyTransactionConfig

      protected void applyTransactionConfig(com.ibatis.sqlmap.client.SqlMapClient sqlMapClient, com.ibatis.sqlmap.engine.transaction.TransactionConfig transactionConfig)
      Deprecated.
      Apply the given iBATIS TransactionConfig to the SqlMapClient.

      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.

      Parameters:
      sqlMapClient - the SqlMapClient to apply the TransactionConfig to
      transactionConfig - the iBATIS TransactionConfig to apply
      See Also:
      • ExtendedSqlMapClient
      • SqlMapExecutorDelegate.getMaxTransactions()
      • SqlMapExecutorDelegate.setTxManager(TransactionManager)
    • getObject

      public com.ibatis.sqlmap.client.SqlMapClient getObject()
      Deprecated.
      Specified by:
      getObject in interface org.springframework.beans.factory.FactoryBean<com.ibatis.sqlmap.client.SqlMapClient>
    • getObjectType

      public Class<? extends com.ibatis.sqlmap.client.SqlMapClient> getObjectType()
      Deprecated.
      Specified by:
      getObjectType in interface org.springframework.beans.factory.FactoryBean<com.ibatis.sqlmap.client.SqlMapClient>
    • isSingleton

      public boolean isSingleton()
      Deprecated.
      Specified by:
      isSingleton in interface org.springframework.beans.factory.FactoryBean<com.ibatis.sqlmap.client.SqlMapClient>