Skip to content

了解limit的用法

Jiale.Chan edited this page Jun 21, 2017 · 2 revisions

limit的用法:(第一个参数为开始位置,第二个参数为获取的条数)

List<Users> result = userDAO.select().where("age < ?", 20).limit(0, 1).execAsList();
List<Map<String, Object>> result = userDAO.select().where("age < ?", 20).limit(0, 1).execAsRows(); 

查询结果

+----+-----------+-----+
| id | name      | age |
+----+-----------+-----+
|  1 | jialechan |   8 |
+----+-----------+-----+
注:limit()方法的第二个参数len必需大于0,否则会获得IllegalArgumentException异常

Clone this wiki locally