There is no getter for property named 'id' in 'class java.lang.Integer

There is no getter for property named 'id' in 'class java.lang.Integer

Problem Description:

Use mybatis pass parameters when the parameter type is when these String, Integer and so on. If his <if test="id != null and id != ''">label to determine whether this parameter is empty, usually burst There is no getter for property named ' id' in 'class java.lang.Integer exception.

Solutions:

  • Before the interface parameters of the method plus @Param ( "parameter name") notes.
    E.g:
    List<String> query(@Param(value="id") Integer id);
  • Baidu when I found that there are people like this solved, I do not know whether feasible, together excerpt:
    should be used _parameter in xml file in place of the parameter name.
    E.g:
<select id="query" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
        <include refid="Base_Column_List" />
    from t_user
    where 1=1
          <if test="_parameter!= null" >
             and  id = #{_parameter}
          </if>
  </select>

to sum up:

Actually, this is not very big, but easy to accidentally commit a trespass; they must be careful.

Guess you like

Origin www.cnblogs.com/mmzs/p/11139233.html