// Mapper.javaEmerEvent selectByAlarmId(Integer alarmId);// Mapper.xml<select id="selectByAlarmId" resultMap="BaseResultMap" parameterType="java.lang.Integer"> select <include refid="Base_Column_List" /> from event <where> <if test="alarmId != null"> and alarm_id = #{alarmId,jdbcType=Integer} </if> </where></select>Since only one parameter is passed: alarmId, the corresponding SQL in the configuration file uses the if tag, and then an error is reported:
nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'alarmId' in 'class java.lang.Integer'
Solution:
1. Remove the if judgment in the SQL statement in the mapper configuration file
<select id="selectByAlarmId" resultMap="BaseResultMap" parameterType="java.lang.Integer"> select <include refid="Base_Column_List" /> from event where alarm_id = #{alarmId,jdbcType=Integer}</select>2. If you want to use if tags, wrap the parameter alarmId into an object or map
Summarize
The above is the problem and solution to the use of single parameters and <if> tags of Mybatis flyers introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to Wulin.com website!