Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于一个分页查询,不知道是不是bug #521

Closed
jy9525 opened this issue Sep 13, 2013 · 2 comments
Closed

关于一个分页查询,不知道是不是bug #521

jy9525 opened this issue Sep 13, 2013 · 2 comments

Comments

@jy9525
Copy link

jy9525 commented Sep 13, 2013

调试发现对于数据库H2,执行分页代码,第一页的时候:List peoplepage = dao.query(Person.class, Cnd.where("age", ">", 18), dao.createPager(1, 2));
日志打印:"SELECT * FROM t_person WHERE age>18 LIMIT 2 OFFSET 0 "
第二页的时候:
List peoplepage = dao.query(Person.class, Cnd.where("age", ">", 18), dao.createPager(2, 2));
日志打印:"SELECT * FROM t_person WHERE age>18 LIMIT 2 OFFSET 2"
明显跳过了 OFFSET 1 ,测试数据后发现,确实当中有数据一页数据跳过。

可否解释下?

@wendal
Copy link
Member

wendal commented Sep 13, 2013

LIMIT limits the number of rows returned by the query (no limit if null or smaller than zero). OFFSET specified how many rows to skip.
SELECT * FROM t_person WHERE age>18 LIMIT 2 OFFSET 2
跳过2条, 取2条
不就是第二页的2条记录吗?

@wendal wendal closed this as completed Sep 13, 2013
@jy9525
Copy link
Author

jy9525 commented Sep 13, 2013

失误,数据看错了,以为H2分页跟mysql分页搞混了,不好意思

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants