8
回答
iBatis动态查询Date型返回值问题求援
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

配置文件如下:
sqlMapConfig部分
<typeHandler javaType="java.sql.Date" jdbcType="DATE" callback="com.dao.TimestampTypeHandlerCallback"/>
<typeHandler javaType="java.util.Date" jdbcType="TIME" callback="com.dao.TimestampTypeHandlerCallback"/>
<typeHandler javaType="java.sql.Timestamp" jdbcType="TIMESTAMP" callback="com.TimestampTypeHandlerCallback"/>
sqlMap配置:
<select id="query" parameterClass="FlowDialUserRpt" resultClass="java.util.HashMap" remapResults="true">
SELECT 
<iterate property="groupFieldsList" conjunction=",">
$groupFieldsList[]$
</iterate>
,
<iterate property="fieldsList" conjunction=",">
$fieldsList[]$
</iterate>
from ( SELECT ROWNUM ROW_ID, T.* FROM (
SELECT 
<iterate property="groupFieldsList" conjunction=",">
$groupFieldsList[]$
</iterate>
,
<iterate property="functionFieldsList" conjunction=",">
$functionFieldsList[]$
</iterate>
from FLOW_DIAL_USER_SUMFLOW_RPT
WHERE DATA_TYPE = #dataType#
<isNotEmpty prepend="AND" property="userAccount">
USER_ACCOUNT=#userAccount#
</isNotEmpty>
<isNotEmpty prepend="AND" property="flowDirection">
FLOW_DIRECTION=#flowDirection#
</isNotEmpty>
<isNotEmpty prepend="AND" property="fromDate">
<![CDATA[ 
UPDATE_DATE>=#fromDate#
]]>
</isNotEmpty>
<isNotEmpty prepend="AND" property="toDate">
<![CDATA[
UPDATE_DATE<=#toDate#
]]>
</isNotEmpty>
<iterate property="groupFieldsList" open="GROUP BY " conjunction=",">
$groupFieldsList[]$
</iterate>
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderStr">
$orderStr$
</isNotEmpty>
</dynamic>
) T
<isNotEqual property="start" compareValue="0">
<isNotEqual property="end" compareValue="0">
WHERE ROWNUM <![CDATA[ < ]]>
= #end#
</isNotEqual>
</isNotEqual>
)
<isNotEqual property="start" compareValue="0">
<isNotEqual property="end" compareValue="0">
WHERE ROW_ID <![CDATA[ > ]]>
= #start#
</isNotEqual>
</isNotEqual>
</select>
现在的问题是:在查询返回值中在oracle中Date型数值,返回到Map中总是被封装为Java.sql.Date类型,改类型有个问题:时间值只能精确到天,而实际需要精确到秒,于是我写了在sqlMapConfig中写了那样的typeHandler ,但是发现该typeHandler总是没有被这个查询调用,这个问题已经困扰两天了,请精通这部分知识的高手赐教!

举报
hexiangmin
发帖于7年前 8回/2K+阅
顶部