Wednesday, 11 September 2013

What's wrongof the MyBatis SQL?

What's wrongof the MyBatis SQL?

I've got two sql in MyBatis, the first one is a query result, and the
second one tries to get the count of the first one. the first sql:
<select id="getFeedbackEntities" resultType="map" parameterType="map">
SELECT * FROM feed_back
WHERE (DATE(sumit_time) BETWEEN #{startDate} AND #{endDate})
AND (comment LIKE #{keyword} OR city LIKE #{keyword} OR isp LIKE
#{keyword})
<if test="type > 0">
AND type = #{type}
</if>
<if test="reason > 0">
AND reason = #{reason}
</if>
ORDER BY #{sort} #{order} LIMIT #{offset}, #{limit}
</select>
the second sql is:
<select id="getFeedbackCount" resultType="int" parameterType="map">
SELECT COUNT(1) FROM feed_back
WHERE (DATE(sumit_time) BETWEEN #{startDate} AND #{endDate})
AND (comment LIKE #{keyword} OR city LIKE #{keyword} OR isp LIKE
#{keyword})
<if test="type > 0">
AND type = #{type}
</if>
<if test="reason > 0">
AND reason = #{reason}
</if>
</select>
I called them with the same parameters. The two sql work fine in seperate
environment, while in the webapp, the second one got the wrong result. I'm
really confused.

No comments:

Post a Comment