錯誤總結-myBatis plus 分頁

錯誤總結-myBatis plus 分頁

今天碰到了一個神奇的問題:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
### The error may exist in cn/edu/zucc/sso/dao/RoleDao.java (best guess)
### The error may involve cn.edu.zucc.sso.dao.RoleDao.selectPage
### The error occurred while handling results
### SQL: SELECT  role_id,role_name  FROM role LIMIT ?,?
### Cause: java.lang.IndexOutOfBoundsException: Index: 2, Size: 2

當前使用了Mybatis plus 使用分頁查詢
service層中框架中自動實現的page方法

@Override
public IPage<BeanRole> loadPage(int page, int pageSize) {
    Page<BeanRole> page1 = new Page<>(page, pageSize);
    System.out.println(JSON.toJSONString(page1));
    return page(page1);
}

最後定位到的錯誤是lombox的註解問題

@Data
@Builder
@TableName("role")
public class BeanRole {
    @TableId(type = IdType.AUTO)
    private int roleId;
    private String roleName;

    @TableField(exist = false)
    private Set<BeanPermission> permissions;
}

由@Builder同時使用造成的異常
使用@Builder 而造成其生成了全參構造器,無參構造器不存在導致實例化異常

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章