マイバティス:
何がうまくいかないのかわからない..しかし、基本的な SelectOne は結果を返していません。
マッパー:
<select id="getBackLog" parameterType="string"
resultType="string">
select data_key from yfs_task_q where task_q_key = #{value}
</select>
方法:
dataKey = (文字列) session.selectOne("OMSWatchMappers.getBackLog", agent); logger.debug("@Backlog=" + dataKey);
ログ:
02:01:34.786 [main] DEBUG o.a.i.t.jdbc.JdbcTransaction - Openning JDBC Connection
02:01:35.890 [main] DEBUG o.a.i.d.pooled.PooledDataSource - Created connection 2092843500.
02:01:35.961 [main] DEBUG c.b.o.r.OMSWatchMappers.getBackLog - ooo Using Connection [oracle.jdbc.driver.T4CConnection@7cbe41ec]
02:01:35.961 [main] DEBUG c.b.o.r.OMSWatchMappers.getBackLog - ==> Preparing: select data_key from yfs_task_q where task_q_key = ?
02:01:36.126 [main] DEBUG c.b.o.r.OMSWatchMappers.getBackLog - ==> Parameters: 201101070640191548867209(String)
02:01:36.249 [main] DEBUG OMSWatchDAOImpl - @Backlog=null
02:01:36.250 [main] DEBUG o.a.i.t.jdbc.JdbcTransaction - Resetting autocommit to true on JDBC Connection [oracle.jdbc.driver.T4CConnection@7cbe41ec]
02:01:36.250 [main] DEBUG o.a.i.t.jdbc.JdbcTransaction - Closing JDBC Connection [oracle.jdbc.driver.T4CConnection@7cbe41ec]
02:01:36.250 [main] DEBUG o.a.i.d.pooled.PooledDataSource - Returned connection 2092843500 to pool.
このレコードはデータベースに存在します。
select data_key from yfs_task_q where task_q_key = '201101070640191548867209';
DATA_KEY
------------------------
201101070636011548866830
パラメータを直接追加するようにマッパーを変更すると、結果が返されます。
マッパー:
<select id="getBackLog" parameterType="string" resultType="string">
select data_key from yfs_task_q where task_q_key = '201101070640191548867209'
</select>
ログ:
02:38:52.746 [main] DEBUG c.b.o.r.OMSWatchMappers.getBackLog - ==> Preparing: select data_key from yfs_task_q where task_q_key = '201101070640191548867209'
02:38:52.942 [main] DEBUG c.b.o.r.OMSWatchMappers.getBackLog - ==> Parameters:
02:38:53.096 [main] DEBUG OMSWatchDAOImpl - @Backlog=201101070636011548866830
ここに欠けている基本的なものがあります。指摘する際の助けは大歓迎です。