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>
数据库里面的 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调用orcale存储过程-传入多个参数返回结果集
- MyBatis的返回参数类型和查询结果遍历
- Flex通过RemoteObject调用java实例:flex传入参数以及接收java返回结果
- MyBatis的传入和返回参数类型
- springboot+mybatis MyBatis查询返回Map时设置值为null的字段没有在结果集中
- mybatis查询没有返回结果,程序不继续执行
- 表不存在,但是可以查询、删除(没有返回结果,一直hang住)
- mybatis 使用oracle char 字段查询返回结果总是null
- mybatis调用orcale存储过程-传入多个参数返回单个字符
- Mybatis插入操作 主键自增 返回成功 但是数据库没有数据
- mybatis 使用oracle查询返回结果总是null
- 使用MyBatis查询 返回类型为int,但是当查询结果为空NULL,报异常的解决方法
- MyBatis第三种方式,xml和接口的结合,以及如何获得插入数据的返回参数、传入空的参数
- 在使用mybatis时遇到查询结果返回为空的情况,但是查数据库能查到
- 使用ShellExecuteEx调用控制台程序或命令行,传入多个参数,并等待返回结果
- Mybatis 在 insert 之后想获取自增的主键 id,但是总是返回1
- WinForm_存储过程-传入参数返回结果集
- 好947 Mybatis 配置resultMap 带参数查询Map 注意selectOne数据库返回结果一条数据库 否则会报错
- MyBatis-执行插入语句的时候返回主键ID到传入的参数对象中
- 传入6个参数,返回一个结果集