jp.terasoluna.fw.orm.ibatis.support
クラス ClobReaderTypeHandler

java.lang.Object
  上位を拡張 com.ibatis.sqlmap.engine.type.BaseTypeHandler
      上位を拡張 org.springframework.orm.ibatis.support.AbstractLobTypeHandler
          上位を拡張 jp.terasoluna.fw.orm.ibatis.support.ClobReaderTypeHandler
すべての実装されたインタフェース:
com.ibatis.sqlmap.engine.type.TypeHandler

public class ClobReaderTypeHandler
extends org.springframework.orm.ibatis.support.AbstractLobTypeHandler

iBATISから利用されるCLOBと文字ストリームをマッピングする実装のiBATISのタイプハンドラ。

CLOB列をバイト配列として扱う場合、本クラスを利用する必要がない。 バイト配列として扱うと、 CLOB列で扱うデータが巨大でメモリエラーが発生したり、 性能要件が満たせない場合のみ、本クラスを利用すること。

内部でSpringが提供しているLobHandlerを利用しているため、 本クラスを利用するためには、LobHandlerのBean定義とsqlMapClientFactoryBeanへの設定を行うこと。 なお、LobHandlerの実装クラスは、Springが提供している。
※ Oracleの場合は、OracleLobHandler、その他の場合は、DefaultLobHandlerを利用すること。

Bean定義ファイルの設定例】

   <!-- LOBフィールドを扱うためのハンドラ -->
   <bean id="oracleLobHandler"
            class="org.springframework.jdbc.support.lob.OracleLobHandler">
     <property name="nativeJdbcExtractor" ref="simpleExtractor"/>
   </bean>

   <!-- iBATIS データベース層のためのSQlMapの設定 -->
   <bean id="sqlMapClient"
       class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
     <property name="configLocation" value="WEB-INF/sql-map-config.xml"/>
     <property name="dataSource" ref="dataSource"/>
     <property name="lobHandler" ref="oracleLobHandler"/>
   </bean>
 

本クラスを利用したiBATIS設定ファイルの記述方法を以下にしめす。

【CLOB_TESTテーブル定義】

列名 制約
PK INTEGER NOT NULL
MAP CLOB NOT NULL

iBATIS設定ファイルの設定例】

 <!? update文の設定 -->
 <parameterMap id="clobParam" class="java.util.Map">
   <parameter property="pk"/>
   <parameter property="map"
       typeHandler="jp.terasoluna.fw.orm.ibatis.support.ClobReaderTypeHandler"/>
 </parameterMap>

 <insert id="insertCLobTest" parameterMap="clobParam">
   INSERT INTO CLOB_TEST (PK, MAP) VALUES (?, ?)
 </insert>

 <!? select文の設定 -->
 <resultMap id="clobResult" class="java.util.HashMap">
   <result property="pk"/>
   <result property="map"
       typeHandler="jp.terasoluna.fw.orm.ibatis.support.ClobReaderTypeHandler"/>
 </resultMap>

 <select id="selectCLobTest" resultMap="clobResult">
   SELECT PK, MAP FROM CLOB_TEST
 </select>
 


フィールドの概要
 
クラス org.springframework.orm.ibatis.support.AbstractLobTypeHandler から継承されたフィールド
LOB_CREATOR_SYNCHRONIZATION_ORDER
 
コンストラクタの概要
  ClobReaderTypeHandler()
          コンストラクタ。
protected ClobReaderTypeHandler(org.springframework.jdbc.support.lob.LobHandler lobHandler)
          コンストラクタ。
 
メソッドの概要
protected  java.lang.Object getResultInternal(java.sql.ResultSet rs, int index, org.springframework.jdbc.support.lob.LobHandler lobHandler)
          結果を取得する。
protected  void setParameterInternal(java.sql.PreparedStatement ps, int index, java.lang.Object value, java.lang.String jdbcType, org.springframework.jdbc.support.lob.LobCreator lobCreator)
          パラメータを設定する。
 java.lang.Object valueOf(java.lang.String s)
          文字列を本Handlerが扱う型に変換する。
 
クラス org.springframework.orm.ibatis.support.AbstractLobTypeHandler から継承されたメソッド
getResult, getResult, getResult, setParameter
 
クラス com.ibatis.sqlmap.engine.type.BaseTypeHandler から継承されたメソッド
equals
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

ClobReaderTypeHandler

public ClobReaderTypeHandler()
コンストラクタ。


ClobReaderTypeHandler

protected ClobReaderTypeHandler(org.springframework.jdbc.support.lob.LobHandler lobHandler)
コンストラクタ。

パラメータ:
lobHandler - LobHandler
メソッドの詳細

setParameterInternal

protected void setParameterInternal(java.sql.PreparedStatement ps,
                                    int index,
                                    java.lang.Object value,
                                    java.lang.String jdbcType,
                                    org.springframework.jdbc.support.lob.LobCreator lobCreator)
                             throws java.sql.SQLException
パラメータを設定する。

定義:
クラス org.springframework.orm.ibatis.support.AbstractLobTypeHandler 内の setParameterInternal
パラメータ:
ps - セット先のPreparedStatement
index - パラメータのインデックス
value - セットするパラメータ
jdbcType - パラメータのJDBC型
lobCreator - 利用するLobCreator
例外:
java.sql.SQLException - SQL例外

getResultInternal

protected java.lang.Object getResultInternal(java.sql.ResultSet rs,
                                             int index,
                                             org.springframework.jdbc.support.lob.LobHandler lobHandler)
                                      throws java.sql.SQLException
結果を取得する。

定義:
クラス org.springframework.orm.ibatis.support.AbstractLobTypeHandler 内の getResultInternal
パラメータ:
rs - 取得元のResultSet
index - ResultSetのインデックス
lobHandler - 利用するLobHandler
戻り値:
取得結果
例外:
java.sql.SQLException - SQL例外

valueOf

public java.lang.Object valueOf(java.lang.String s)
文字列を本Handlerが扱う型に変換する。

パラメータ:
s - 文字列
戻り値:
Handlerが扱う型のインスタンス