HQL问题

三张表table_role角色,table_org_ur组织和用户中间表,table_organization组织表。

查询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}%'


分页统计总条数的sql:

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%')

页面呈现的数据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 改用其他的去重复方法。

各位大神,你的看法呢?谢了

你可能感兴趣的:(hql去重,分页问题)