三張表table_role角色,table_org_ur組織和用戶中間表,table_organization組織表。 sql
查詢table_role表裏面有21條數據,可是重複數據不少,去distinct重複以後只有8條,可是分頁顯示21條。頁面只有8條。 源碼
HQL:select distinct role from AuthRole role,AuthOrgUR our,AuthOrganization ao where role.roleId=our.urId
and ao.organizationId=our.organizationId and our.type=1 and ao.organizationPath like '$!{organizationPath}%' io
分頁統計總條數的sql: table
select count(*) as c_0_0
from IC_AUTH_ROLES authrole0_
cross join IC_AUTH_ORG_UR authorgur1_
cross join IC_AUTH_ORGANIZATION authorgani2_
where authrole0_.ROLE_ID = authorgur1_.UR_ID
and authorgani2_.ORGANIZATION_ID = authorgur1_.ORGANIZATION_ID
and authorgur1_.TYPE = 1
and authorgani2_.ORGANIZATION_PATH like '1%') select
頁面呈現的數據sql: 分頁
select *
from (select distinct authrole0_.ROLE_ID as ROLE1_1_,
authrole0_.ROLE_NAME as ROLE2_1_,
authrole0_.REMARK as REMARK1_,
authrole0_.SYSTEM_TYPE as SYSTEM4_1_,
authrole0_.CREATOR as CREATOR1_,
authrole0_.CREATE_TIME as CREATE6_1_,
authrole0_.LAST_MODIFIER as LAST7_1_,
authrole0_.LAST_MODIFY_TIME as LAST8_1_
from IC_AUTH_ROLES authrole0_
cross join IC_AUTH_ORG_UR authorgur1_
cross join IC_AUTH_ORGANIZATION authorgani2_
where authrole0_.ROLE_ID = authorgur1_.UR_ID
and authorgani2_.ORGANIZATION_ID = authorgur1_.ORGANIZATION_ID
and authorgur1_.TYPE = 1
and (authorgani2_.ORGANIZATION_PATH like '1%')
order by authrole0_.ROLE_ID desc)
有位同事說分頁拼接的地方有問題,改分頁源碼,有位說hql問題,去掉distinct 改用其餘的去重複方法。 方法
各位大神,你的見解呢?謝了
統計