Hibernate 的分页代码
query.setFirstResult(7682);
query.setMaxResults(10);
List list = query.list();
通过跟踪数据库检测器,如下
declare @p1 int
set @p1=0
declare @p2 int
set @p2=0
declare @p7 int
set @p7 =0
exec sp_cursorprepexec @p1 output,@p2 output,NULL,N'select top 76820 this_.FGuid as FGuid7_0_, this_.FM6 as FM2_7_0_, this_.FcPp as FcPp7_0_, this_.FM1 as
FM4_7_0_, this_.FcXh as FcXh7_0_, this_.FDhh as FDhh7_0_, this_.FcLb as FcLb7_0_, this_.FCBZ as FCBZ7_0_, this_.FcXl as FcXl7_0_, this_.FCdw as FCdw7_0_,
this_.Fd3 as Fd11_7_0_ from bap.dbo.B_CMS_Productinfo this_ where (1=1) order by this_.FGuid asc',8,1,@p7 output
select @p1, @p2, @p7
--exec sp_cursorfetch 180150011,2,0,128
exec sp_cursorfetch 180150011,16,76810,128
可以看出hibernate 在sql server 2005的最关键在与存储过程
exec sp_cursorprepexec(Prepare a cursor statement and open)