mybatis查询时报
There is no getter for property named ‘xxxx’ in ‘class java.lang.Integer’ 错误。查看sql发现有一个Integer类型的参数,以下为sql写法:
SELECT
<include refid="Base_Column_List" />
FROM hotel
<where>
1=1
<if test="hotelPkid != null and hotelPkid != ''">
AND hotel_pkid =#{hotelPkid }
</if>
<if test="hotelName != null and hotelName != ''">
AND hotel_name like concat('%', #{hotelName} ,'%')
</if>
</where>
ORDER BY hotel_pkid
此处报 There is no getter for property named ‘hotelPkid ’ in ‘class java.lang.Integer
从网上查了些资料,解决方法有两种:
1、将 参数名称 “hotelPkid ” 替换为”_parameter” ,结果正常。
2. 在mapper接口中定义方法时增加“@Param(“hotel_pkid “)”,即
List listHotel(@Param(“hotelPkid “)int (hotelPkid );
经本人亲测:方法一可行,方法二不可行,具体原因参考深入了解Mybatis参数
另外对于方法一也可以将_parameter 改为 value 也是可以的!具体原因参考深入了解Mybatis参数!
参考:
http://blog.csdn.net/moneyshi/article/details/45914467
http://blog.sina.com.cn/s/blog_8ced01900101blqd.html