三张表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 改用其余的去重复方法。 方法
各位大神,你的见解呢?谢了
统计