Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.Integer'
报错原因:
<select id="selectUser" parameterType="int" resultType="User"> select * from user where <if test=" id != null ">id = #{id}</if> </select>
修改代码:
<select id="selectUser" parameterType="int" resultType="User"> select * from user where id=#{id} </select>
或者
<select id="selectUser" parameterType="int" resultType="User"> select * from user where <if test=" _parameter != null ">id = #{_parameter}</if> </select>
引起原因,网上说是:
Mybatis默认采用ONGL解析参数,所以会自动采用对象树的形式取Integer.id值,引起报错
相关推荐
在实际开发过程中,我们往往需要编写复杂的SQL语句,拼接稍有不注意就会导致错误,Mybatis给开发者提供了动态SQL,大大降低了拼接SQL导致的错误。 动态标签 if标签 if标签通常用那个胡where语句,update语句,insert...
mybatis获取自增IDmybatis获取自增ID
非常好用的,就是你们所要的 Mybatis日志参数快速替换占位符 sql参数替换工具html
总结了Mybatis传递参数的几种方式,并对几种方式进行比较,另外还有一些参数的限制说明
深入了解MyBatis参数
mybatis中内置的全局参数,用于学习mybatis框架,在不确定是否有该别名的时候可以查查这份文档
Mybatis Log(自动填充sql参数打印到控制台)
项目中的代码截取自mybatis-plus-3.5项目源码中分布式ID的实现,主要是内容是Mybatis-plus项目中IdentifierGenerator接口的两个实现类DefaultIdentifierGenerator和ImadcnIdentifierGenerator的源码,还有IdWorker工具...
MyBatis传入多个参数
MyBatis拦截器分页与动态修改SQL及其参数值 提取SQL Like 字段
Mybatis多参数查询与列表查询不同方式实现,效果看博文 http://blog.csdn.net/evankaka/article/details/45671473
下面小编就为大家带来一篇MyBatis拦截器:给参数对象属性赋值的实例。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
使用Map 映射文件 ...DOCTYPE mapper PUBLIC "-//... <select id="selectStudentByNameAndAge" resultType="Student" parameterType="map"> select * from stu_tbl where name = #{name} and age = #{age} </mapper>
MyBatis排序时使用order by 动态参数时需要注意,用$而不是# 字符串替换 默认情况下,使用#{}格式的语法会导致MyBatis创建预处理语句属性并以它为背景设置安全的值(比如?)。这样做很安全,很迅速也是首选做法,...
[html] view plain copy id="queryMessageList" parameterType="java.util.M
我们看到, 直接在可视化工具里用SQL写 ccf.last_update_timestamp between TIMESTAMP '2019-12-13' AND TIMESTAMP '2019-12-13' 甚至去掉 TIMESTAMP 都是可以的, pgSQL可以自动把字符串给你转换成日期格式, ...
主要介绍了MyBatis 参数类型为String时常见问题及解决方法,非常不错,具有参考借鉴价值,需要的朋友可以参考下
mybatis 自定义生成 entity/dao/mapper.xml 文件