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

来源:互联网 发布:开淘宝网店需要多少钱 编辑:程序博客网 时间:2024/05/21 02:49

 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>

阅读全文
0 0
原创粉丝点击