intra-mart Accel Platform / セットアップガイド

«  TERASOLUNA Global Framework用設定ファイル (リポジトリ層にJPAを利用する場合)   ::   コンテンツ   ::   Apache Cassandra ( IMBox を利用する場合)  »

TERASOLUNA Global Framework用設定ファイル (リポジトリ層にMyBatisを利用する場合)

TERASOLUNA Global Frameworkのリポジトリ層にMyBatisを利用する場合、下記設定ファイルの確認および変更が必要となります。

テナントデータベース用の設定

  • テナントデータベース用の設定は、classes/META-INF/spring/applicationContext-mybatis.xmlファイルに設定されており、初期設定のままご利用ください。

    <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" scope="singleton">
        <property name="configLocations" value="classpath*:/META-INF/mybatis/config/*sqlMapConfig.xml" />
        <property name="mappingLocations" value="classpath*:/META-INF/mybatis/sql/**/*-sqlmap.xml" />
        <property name="dataSource" ref="dataSource" />
    </bean>
    
    <bean id="queryDAO"
        class="jp.terasoluna.fw.dao.ibatis.QueryDAOiBatisImpl">
        <property name="sqlMapClient" ref="sqlMapClient" />
    </bean>
    
    <bean id="updateDAO"
        class="jp.terasoluna.fw.dao.ibatis.UpdateDAOiBatisImpl">
        <property name="sqlMapClient" ref="sqlMapClient" />
    </bean>
    
    <bean id="spDAO"
        class="jp.terasoluna.fw.dao.ibatis.StoredProcedureDAOiBatisImpl">
        <property name="sqlMapClient" ref="sqlMapClient" />
    </bean>
    
    <bean id="queryRowHandleDAO"
        class="jp.terasoluna.fw.dao.ibatis.QueryRowHandleDAOiBatisImpl">
       <property name="sqlMapClient" ref="sqlMapClient" />
    </bean>
    

シェアードデータベースを利用する場合の設定

  • classes/META-INF/spring/applicationContext-mybatis.xmlファイルの編集を行います。

    1. applicationContext-mybatis.xml の下記コメントアウトをはずして、 <bean id=”sharedSqlMapClient”>のdataSourceプロパティのref値には、applicationContext-im_tgfw_common.xmlファイルで登録したシェアードデータソースのBeanのidを指定してください。
    <bean id="sharedSqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" scope="singleton">
        <property name="configLocations" value="classpath*:/META-INF/mybatis/config/*sqlMapConfig.xml" />
        <property name="mappingLocations" value="classpath*:/META-INF/mybatis/sql/**/*-sqlmap.xml" />
        <property name="dataSource" ref="sharedDataSource" />
    </bean>
    
    <bean id="sharedQueryDAO"
        class="jp.terasoluna.fw.dao.ibatis.QueryDAOiBatisImpl">
        <property name="sqlMapClient" ref="sharedSqlMapClient" />
    </bean>
    
    <bean id="sharedUpdateDAO"
        class="jp.terasoluna.fw.dao.ibatis.UpdateDAOiBatisImpl">
        <property name="sqlMapClient" ref="sharedSqlMapClient" />
    </bean>
    
    <bean id="sharedSpDAO"
        class="jp.terasoluna.fw.dao.ibatis.StoredProcedureDAOiBatisImpl">
        <property name="sqlMapClient" ref="sharedSqlMapClient" />
    </bean>
    
    <bean id="sharedQueryRowHandleDAO"
        class="jp.terasoluna.fw.dao.ibatis.QueryRowHandleDAOiBatisImpl">
        <property name="sqlMapClient" ref="sharedSqlMapClient" />
    </bean>
    

    コラム

    複数のシェアードデータベースを利用する場合は、SqlMapClientFactoryBean / QueryDAOiBatisImpl / UpdateDAOiBatisImpl / StoredProcedureDAOiBatisImpl / QueryRowHandleDAOiBatisImpl それぞれ新規にbeanを定義してください。次に、SqlMapClientFactoryBeanのdataSourceプロパティのref値に接続先のシェアードデータベースのBeanのidを指定してください。またQueryDAOiBatisImpl / UpdateDAOiBatisImpl / StoredProcedureDAOiBatisImpl / QueryRowHandleDAOiBatisImplのそれぞれのBeanのsqlMapClientプロパティには、SqlMapClientFactoryBeanのBeanのidを指定してください。

«  TERASOLUNA Global Framework用設定ファイル (リポジトリ層にJPAを利用する場合)   ::   コンテンツ   ::   Apache Cassandra ( IMBox を利用する場合)  »