Mybatis substantially non-empty type parameter is determined (exception: There is no getter for property ...)

Look at the piece of code

<select id="queryByPhone" parameterType="java.lang.String" resultType="com.ccnc.bean.user.QuickUser">  
    select   
     *  
    from  quick_user where   
    <if test="phone != null" >  
       and phone = #{phone}  
    </if>  
  </select>

Glance and there is no problem, will be reported execution There is no getter for property phone ......

The reason is that at the time of mybatis <if> resolved, the object is to get parameterType specified in the respective property, if the specified object is a complex object, is operating normally. Here is the basic type String, the String class to find the phone will go get and set methods, so the error.

Proper code, remove the parameterType, while adding annotations corresponding dao @Praram

<select id="queryByPhone"  resultType="com.ccnc.bean.user.QuickUser">  
    select   
     *  
    from  quick_user where   
    <if test="phone != null" >  
       and phone = #{phone}  
    </if>  
  </select>
public  interface quickUserDao { 

Quick User queryByPhone (@Praram ( "phone" ) String phone); 
}

 

Guess you like

Origin www.cnblogs.com/zxxfz/p/11987980.html