码迷,mamicode.com
首页 > 编程语言 > 详细

Mybatis 报错 There is no getter for property named '***' in 'class java.lang.String'

时间:2017-09-04 19:44:18      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:null   select   string类   getter   for   named   java   语句   when   

  在mapper.xml中 , 如果单参数是String类型 , 且在sql语句中对参数进行了判断 , 如下 when 中的判断 , 如果出现 if 判断也是一样的。都需要把判断中的参数用 _parameter 来代替 ,。

  另外orcal中判断字段是否为空需要使用 is null , 同理,判断不为空使用 is not null 。

  错误查询:

<select id = "select"  resultMap="ResultMap" parameterType="String">
select
name,code,parent,level
from
table
<where>
<choose>
<when test="code != null and code !=‘‘">
and code = #{code}
</when>
<otherwise>
and code is null
</otherwise>
</choose>
</where>
</select>

  正确查询:


<select id = "select" resultMap="ResultMap" parameterType="String">
select
name,code,parent,level
from
table
<where>
<choose>
<when test="_parameter !=null and _parameter !=‘‘">
and code = #{code}
</when>
<otherwise>
and code is null
</otherwise>
</choose>
</where>
</select>

Mybatis 报错 There is no getter for property named '***' in 'class java.lang.String'

标签:null   select   string类   getter   for   named   java   语句   when   

原文地址:http://www.cnblogs.com/gczmn/p/7475113.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!