您的位置:首页 > 编程语言 > Java开发

myBatis 传入的参数是对的,但是总是没有返回结果

2017-12-16 19:31 288 查看
 myBatis 传入的参数是对的,但是总是没有返回结果!

数据库里面的 column type 是 CHAR!

所以你在比较的时候要在名字前面加上trim() 行数!

下面取出来的值是空的

     <select id = "selectUserByUserNameOrPassword" parameterType="java.util.Map" resultMap="BaseResultMap">
    SELECT * FROM t_users
<where>
<if test="userName != null">
USER_NAME = #{userName}
</if>
<if test="password!=null">
AND USER_PASSWORD = #{password}
</if>
</where>
    </select>

你把它改成就对了

    <select id = "selectUserByUserNameOrPassword" parameterType="java.util.Map" resultMap="BaseResultMap">
    SELECT * FROM t_users
<where>
<if test="userName != null">
trim(USER_NAME) = #{userName}
</if>
<if test="password!=null">
AND
trim(USER_PASSWORD) = #{password}
</if>
</where>
    </select>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mybatis sql spring
相关文章推荐