iBatis から myBatis への移行を行っています。変換中に、以前は機能していたクエリがありましたが、現在は機能していません。私は、これを機能させようとしていると認めたくないほど長い間、頭を壁にぶつけてきました。
iBatis でのクエリは次のとおりです。
<select id="countForACol" parameterClass="java.lang.Long" resultClass="java.lang.Long">
SELECT
COUNT(1) AS 'val'
FROM
someTable WITH(NOLOCK)
<isParameterPresent prepend="WHERE">
someCol = #colId#
</isParameterPresent>
</select>
これを次のようなクエリに変換しました。
<select id="selectTotalRegionCountForGbs" parameterType="Long" resultType="java.lang.Long">
SELECT
COUNT(1) AS 'val'
FROM
someTable WITH(NOLOCK)
<where>
<if test="colId != null">
someCol = #{colId}
</if>
</where>
</select>
ただし、これは機能しません。実行しようとしたときに受け取るエラーは次のとおりです。
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'colId' in 'class java.lang.Long'
Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'colId' in 'class java.lang.Long'
Long オブジェクトを、おそらく存在しない「getColId」というゲッターを持つオブジェクトのように処理しようとしていることがわかりますが、Long の値を使用するように MyBatis に通知する方法がわかりません。
これを機能させるにはどうすればよいですか?