在做后台项目查询MQ消息的时候,报错
代码如下:
- biz
@Override
protected List queryPaging(int startIndex, int pageSize, Object... objs) {
QueryPagingUrlMessageRequest request = (QueryPagingUrlMessageRequest) objs[0];
List<Integer> ids = null;
if (request.getItemId() != null){
ids = itemService.getConfigList(request.getItemId(),Constants.URL_MESSAGE_LIST);
if (CollectionUtils.isEmpty(ids)){
return new ArrayList<>();
}
}
UrlMessageCondition condition = new UrlMessageCondition();
BeanUtils.copyProperties(request,condition);
condition.setIds(ids);
return urlMessageService.pagingQuery(condition,startIndex,pageSize);
}
这里的pagingQuery方法中出现了startIndex,最终是为了mabatis中limit时求开始索引
starrtIndex = pageSize * (pageIndex - 1)
- service
public List<UrlMessage> pagingQuery(UrlMessageCondition condition, int startIndex, int pageSize) {
return mapper.selectByPidAndurlMessageAndCreator(condition,startIndex,pageSize);
}
- mapper
List<UrlMessage> selectByPidAndurlMessageAndCreator(
@Param("condition") UrlMessageCondition condition,
@Param("startIndex") int startIndex,
@Param("pageSize") int pageSize);
!!!问题出在了这里!!!,@Param(“startIndex”) int startIndex ,拼写错误·······导致sql语句的limit #{startIndex},#{pageSize}
中找不到startIndex
- .xml
<select id="selectByPidAndurlMessageAndCreator" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from wpm_config_url_message
where
STATUS=1
<if test="condition.pid != null">
and PID =#{condition.pid}
</if>
<if test="condition.name != null">
and NAME like CONCAT('%',#{condition.name},'%')
</if>
<if test="condition.topic != null">
and TOPIC like CONCAT('%',#{condition.topic},'%')
</if>
<if test="condition.creator != null">
and CREATOR =#{condition.creator}
</if>
<if test="condition.ids != null">
and ID in
<foreach collection='condition.ids' item='id'
open='('
close=')'
separator=','>
#{id}
</foreach>
</if>
<if test="condition.responsibleOwner != null">
and RESPONSIBLE_OWNER =#{condition.responsibleOwner}
</if>
order by ID
limit #{startIndex},#{pageSize}
</select>