首页 > 代码库 > hibernate查询之Criteria实现分页方法(GROOVY语法)

hibernate查询之Criteria实现分页方法(GROOVY语法)

public int searchTest(String name, Integer pageIndex, List<Test> resultList){
    def criteria = Test.createCriteria()
    List testList = criteria.list(max: 10, offset: pageIndex) {
        eq("name", name)
        order("createTime", "desc")
    }

    resultList.addAll(testList)
    int total = resultList.size()
    return total
}

hibernate查询之Criteria实现分页方法(GROOVY语法)