jp.terasoluna.fw.dao.ibatis
クラス StoredProcedureDAOiBatisImpl

java.lang.Object
  上位を拡張 org.springframework.dao.support.DaoSupport
      上位を拡張 org.springframework.orm.ibatis.support.SqlMapClientDaoSupport
          上位を拡張 jp.terasoluna.fw.dao.ibatis.StoredProcedureDAOiBatisImpl
すべての実装されたインタフェース:
StoredProcedureDAO, org.springframework.beans.factory.InitializingBean

public class StoredProcedureDAOiBatisImpl
extends org.springframework.orm.ibatis.support.SqlMapClientDaoSupport
implements StoredProcedureDAO

StoredProcedureDAOインタフェースのiBATIS用実装クラス。

このクラスは、Bean定義ファイルにBean定義を行いサービス層に インジェクションして使用する。以下に設定例および実装例を示す。

Bean定義ファイルの例

<bean id="listBLogic" class="jp.strutspring.blogic.ListBLogic">
  <property name="dao"><ref local="spDAO"/></property>
</bean>

<bean id="spDAO"
  class="jp.terasoluna. fw.dao.ibatis.StoredProcedureDAOiBatisImpl">
  <property name="sqlMapClient"><ref local="sqlMapClient"/></property>
</bean>

<bean id="sqlMapClient"
    class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
  <property name="configLocation">
    <value>sqlMapConfig.xml</value>
  </property>
</bean>

サービス層での使用方法

public class UserGetBLogic{
    private StoredProcedureDAO dao = null;
    public StoredProcedureDAO getDao() {
        return dao;
    }
    public void setDao(StoredProcedureDAO dao) {
        this.dao = dao;
    }

    public String execute(ActionForm form) {

        UserBean userBean = new UserBean();
        userBean.setInputId("1");

        dao.executeForObject("getUserName", userBean);

        String userName = userBean.getName();
        ...
        return "success";
    }
}

iBATISの設定例

<parameterMap id="UserBean" class="jp.strutspring.blogic.UserBean">
   <parameter property="inputId" javaType="java.lang.String" mode="IN"/>
   <parameter property="name" javaType="java.lang.String" mode="OUT"/>
</parameterMap>
<procedure id="getUserName" parameterMap="UserBean">
    {call TESTPROCEDURE(?,?)}
</procedure>


フィールドの概要
 
クラス org.springframework.dao.support.DaoSupport から継承されたフィールド
logger
 
コンストラクタの概要
StoredProcedureDAOiBatisImpl()
           
 
メソッドの概要
 void executeForObject(String sqlID, Object bindParams)
          指定されたSQLIDのストアドプロシージャーを実行する。
 
クラス org.springframework.orm.ibatis.support.SqlMapClientDaoSupport から継承されたメソッド
checkDaoConfig, getDataSource, getSqlMapClient, getSqlMapClientTemplate, setDataSource, setSqlMapClient, setSqlMapClientTemplate
 
クラス org.springframework.dao.support.DaoSupport から継承されたメソッド
afterPropertiesSet, initDao
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

StoredProcedureDAOiBatisImpl

public StoredProcedureDAOiBatisImpl()
メソッドの詳細

executeForObject

public void executeForObject(String sqlID,
                             Object bindParams)
指定されたSQLIDのストアドプロシージャーを実行する。 ストアドプロシージャーの結果であるアウトパラメータは、 引数のbindParamsに反映される。

定義:
インタフェース StoredProcedureDAO 内の executeForObject
パラメータ:
sqlID - 実行するSQLのID
bindParams - SQLにバインドする値を格納したオブジェクト


Copyright © 2011. All Rights Reserved.