mybatis 基本型別的if條件判斷問題 There is no getter for property named 'xxx' in 'class Java.lang.Integer'
阿新 • • 發佈:2019-01-27
mybatis中if test裡判斷傳參時,如果傳參是像int的基本型別,因為它沒有getter方法所以會報錯:There is no getter for property named 'xxx' in 'class java.lang.Integer'
1.修改select語句
- <selectid="sel_campusinfo"parameterType="int"resultType="Campusinfo">
-
select cmpid,cmpname from campusinfo where state!='d' and cmpid!=0
- <iftest="_parameter!=0">and cmpid=#{_parameter}</if>
- </select>
2.不修改sql,只修改介面
介面類:
- Campusinfo sel_campusinfo( int cmpid);
改為:
- Campusinfo sel_campusinfo(@Param(value="cmpid") int cmpid);