【org.mybatis.spring.MyBatisSystemException】There is no getter for property named ‘array‘‘
今天测试功能的时候,报错了。
There is no getter for property named ‘array’ in ‘class com.ruoyi.digital.domain.StatusQueryInfo’
翻译翻译:StatusQueryInfo类中没有名为“array”属性的get方法
我的SQ语句是这样写的。
<select id="selectBuStatusListByMacIds" parameterType="com.ruoyi.digital.domain.StatusQueryInfo" resultMap="BuStatusListResult">
select MachineStatus,AddTimeStamp from BU_Status_List
<where>
<if test="macIds != null "> and Mac_ID in
<foreach item="item" collection="array" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="beginTime != null "> and AddTimeStamp > #{beginTime}</if>
<if test="endTime != null "> and AddTimeStamp < #{endTime}</if>
</where>
order by AddTimeStamp
</select>
我找到其中带有array的语句:
<if test="macIds != null "> and Mac_ID in
<foreach item="item" collection="array" open="(" separator="," close=")">
#{item}
</foreach>
</if>
其中,collection="array"
我不是很懂,这里为什么要这么写?
我是从别的地方粘贴复制的,不过StatusQueryInfo 类中的确没有array
属性,而是Long[] macIds
@Data
public class StatusQueryInfo implements Serializable {
private static final long serialVersionUID = 1L;
/** 开始时间 */
private Long beginTime;
/** 结束时间 */
private Long endTime;
/** 机器Id数组 */
private Long[] macIds;
/** 机器Id */
private Long macId;
}
我抱着试试看的态度,把collection="array"
改成collection="macIds"
。如下:
<select id="selectBuStatusListByMacIds" parameterType="com.ruoyi.digital.domain.StatusQueryInfo" resultMap="BuStatusListResult">
select MachineStatus,AddTimeStamp from BU_Status_List
<where>
<if test="macIds != null "> and Mac_ID in
<foreach item="item" collection="macIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="beginTime != null "> and AddTimeStamp > #{beginTime}</if>
<if test="endTime != null "> and AddTimeStamp < #{endTime}</if>
</where>
order by AddTimeStamp
</select>
然后,程序就可以了。
但是我不知道它为什么就可以了,于是赶紧去查资料。
推荐博客: