myibatis动态SQL报There is no getter for property named 'id' in 'class java.lang.Int
在用动态SQL老一个There is no getter for property named 'id' in 'class java.lang.Integer错误代码如下:
<select id="queryUser" parameterType="Integer"
resultType="com.accp.TestMybatis.dto.User">
select * from scott.users
<if test="id!=null">
where id = #{id}
</if>
</select>
但是把if去掉如:
<select id="queryUser" parameterType="Integer"
resultType="com.accp.TestMybatis.dto.User">
select * from scott.users where id = #{id}
</select>
又正常,非常蛋疼。 --------------------编程问答-------------------- ID设置Long试一下 --------------------编程问答-------------------- 楼主你怎么不用ibatis的isNotNull节点配置呢? --------------------编程问答-------------------- 楼上正确,楼主有点乱用了哈 --------------------编程问答-------------------- 使用大于的那个标签也行的。你使用的标签可能是ibatis后来的特性吧。但是没有过,我们一般都使用大于、小于,notempty notnull。。。。。。。。 --------------------编程问答-------------------- 这是myBatis,我也遇到楼主同样的问题 --------------------编程问答-------------------- 不管你的参数是什么,都要改成"_parameter" http://blog.csdn.net/wubai250/article/details/7991094 --------------------编程问答-------------------- 你的id 是什么类型的?不会是int型的吧?
如果是int的 怎么去和 null比较? 就照错误信息说的改成integer --------------------编程问答-------------------- 擦,没看清楚,当我没说 --------------------编程问答-------------------- Integer等包装类哪有id 的get方法啊 你可以把参数id 存到map或一个实体类对象里面 然后把包装后的当作参数传进去 就OK了 --------------------编程问答--------------------
查了下mybatis的使用文档,没有关于isNotNull的。
你这个在ibatis里面才用吧 --------------------编程问答-------------------- <select id="queryUser" parameterType="Integer"
resultType="com.accp.TestMybatis.dto.User">
select * from scott.users
<if test="id!=null">
where id = #{id}
</if>
</select>
将<if test="id!=null">改为
<if test="_parameter!=null">
where id = #{_parameter}
</if> --------------------编程问答-------------------- 你是直接传的值把,没有map或bean封装把
补充:Java , Web 开发