mybatis "There is no getter for property named 'xx' in 'class java.lang.String"问题
2016-05-19 13:08
465 查看
用mybatis查询时,传入一个字符串参数,且进行判断时,会报There is no getter for property named 'xx' in 'class java.lang.String的错误.
例:
<select id="SelectFeedback" parameterType="String" resultType="com.fjnu.domain.CoachStudent">
SELECT a.id, c.coa_name, c.stu_name, c.cou_name, c.station, c.grade, c.clazz, c.weekday, a.time AS date, a.lateTime, a.remark, a.rate, a.type
FROM t_feedback a, c_s_detail b, Coach_Student c WHERE 1 = 1
AND a.cs_id = b.id
AND b.coa_stu_id = c.id
<if test="station != null and station!= ''">
AND c.station = #{station}
</if>
</select>
传入 station 参数,但是会报错
应改为
<select id="SelectFeedback" parameterType="String" resultType="com.fjnu.domain.CoachStudent">
SELECT a.id, c.coa_name, c.stu_name, c.cou_name, c.station, c.grade, c.clazz, c.weekday, a.time AS date, a.lateTime, a.remark, a.rate, a.type
FROM t_feedback a, c_s_detail b, Coach_Student c WHERE 1 = 1
AND a.cs_id = b.id
AND b.coa_stu_id = c.id
<if test="_parameter != null and _parameter != ''">
AND c.station = #{_parameter}
</if>
</select>
把参数替换为_parameter
原因:Mybatis默认采用ONGL解析参数,所以会自动采用对象树的形式取string.num值,引起报错。
例:
<select id="SelectFeedback" parameterType="String" resultType="com.fjnu.domain.CoachStudent">
SELECT a.id, c.coa_name, c.stu_name, c.cou_name, c.station, c.grade, c.clazz, c.weekday, a.time AS date, a.lateTime, a.remark, a.rate, a.type
FROM t_feedback a, c_s_detail b, Coach_Student c WHERE 1 = 1
AND a.cs_id = b.id
AND b.coa_stu_id = c.id
<if test="station != null and station!= ''">
AND c.station = #{station}
</if>
</select>
传入 station 参数,但是会报错
应改为
<select id="SelectFeedback" parameterType="String" resultType="com.fjnu.domain.CoachStudent">
SELECT a.id, c.coa_name, c.stu_name, c.cou_name, c.station, c.grade, c.clazz, c.weekday, a.time AS date, a.lateTime, a.remark, a.rate, a.type
FROM t_feedback a, c_s_detail b, Coach_Student c WHERE 1 = 1
AND a.cs_id = b.id
AND b.coa_stu_id = c.id
<if test="_parameter != null and _parameter != ''">
AND c.station = #{_parameter}
</if>
</select>
把参数替换为_parameter
原因:Mybatis默认采用ONGL解析参数,所以会自动采用对象树的形式取string.num值,引起报错。
相关文章推荐
- 计算两个非负整数的最大公约数
- JAVA设计模式(16):行为型-策略模式(Strategy)
- 更新Android SDK之后Eclipse提示ADT版本过低的一个简易解决办法
- 细说JAVA反射
- java入门之抽象类
- JAVA设计模式(15):行为型-命令模式(Command)
- java calender 获取本周一与周日的代码
- JAVA设计模式(14):行为型-中介者模式(Mediator)
- 编译原理知识(1)--Java实现本地时间获取
- Spring的工作原理
- 使用RxJava.Observable取代AsyncTask和AsyncTaskLoader
- 2016年排名Top 100的Java类库
- ubuntu下hadoop+eclipse开发环境的搭建
- 不要打断链式结构:使用 RxJava的 compose() 操作符
- java8 lambda尝试
- sift的java实现解述
- 版本控制SVN
- MAC下安装多版本JDK和切换几种方式
- 关于在Java中链接SQLServer数据库中失败的原因分析
- eclipse常用以及实用的快捷键