两个域实体:
public class FunRole implements Serializable {
private static final long serialVersionUID = 1L;
private long id;
private String role;
private Function function;
}
public class Function implements Serializable {
private static final long serialVersionUID = 1L;
private long id;
private String code;
private String desc;
private BigDecimal ftype;
private BigDecimal parentid;
private Set<FunRole> funRoles;
}
有两个表:
many
"FUN_ROLE"
( "ID" NUMBER,
"ROLE" VARCHAR2(40 BYTE),
"FUNCTIONID" NUMBER(foreign key)
)
one:
"FUNCTION"
( "ID" NUMBER(*,0), (primary key)
"CODE" VARCHAR2(40 BYTE),
"DESC" VARCHAR2(4000 BYTE),
"FTYPE" NUMBER(38,0),
"PARENTID" NUMBER(*,0)
)
当我使用jpa和hibernate查询Pagination时,但是第一页结果和第二页有相同的数据,我不知道为什么? jpql查询是:
select g from FunRole g join g.function f where g.role =:role order by g.role asc,f.ftype asc
并且sql是:
select
*
from
( select
car0_.id as id5_,
car0_.FUNCTIONID as FUNCTIONID5_,
car0_."ROLE" as ROLE2_5_
from
FUN_ROLE car0_,
FUNCTION car1_
where
car0_.FUNCTIONID=car1_.id
and car0_."ROLE"='Operator'
order by
car0_."ROLE" asc,
car1_.ftype asc )
where
rownum <= 10;
select
*
from
( select
row_.*,
rownum rownum_
from
( select
car0_.id as id0_,
car0_.FUNCTIONID as FUNCTIONID0_,
car0_."ROLE" as ROLE2_0_
from
FUN_ROLE car0_,
FUNCTION car1_
where
car0_.FUNCTIONID=car1_.id
and car0_."ROLE"='Operator'
order by
car0_."ROLE" asc,
car1_.ftype asc ) row_ )
where
rownum_ <= 10
and rownum_ > 0;
,数据结果为:
the first page data:
id:2150,funId:1051,ftype:1,
id:1,funId:1,ftype:1,
id:27,funId:22,ftype:2,
id:2251,funId:6,ftype:2,
id:2250,funId:5,ftype:2,
id:5,funId:4,ftype:2,
id:24,funId:20,ftype:2,--*reqeat*
id:23,funId:19,ftype:2,--*reqeat*
id:2255,funId:18,ftype:2,--*reqeat*
id:2254,funId:17,ftype:2,--*reqeat*
==============================
the second page data is
id:2102,funId:2100,ftype:2,
id:39,funId:33,ftype:2,
id:2254,funId:17,ftype:2,--*reqeat*
id:2255,funId:18,ftype:2,--*reqeat*
id:23,funId:19,ftype:2,--*reqeat*
id:24,funId:20,ftype:2,--*reqeat*
id:13,funId:11,ftype:3,
id:14,funId:12,ftype:3,
id:12,funId:10,ftype:3,
id:11,funId:9,ftype:3,