Changeset 4199


Ignore:
Timestamp:
Mar 31, 2008, 9:59:42 AM (15 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #959: Users may be duplicated in group member list for quota groups

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6-stable/src/core/net/sf/basedb/core/Group.java

    r4020 r4199  
    2828import net.sf.basedb.core.data.GroupData;
    2929import net.sf.basedb.core.query.EntityQuery;
     30import net.sf.basedb.core.query.Restriction;
    3031import net.sf.basedb.core.query.Restrictions;
    3132import net.sf.basedb.core.query.Hql;
     
    454455    throws BaseException
    455456  {
     457    Restriction thisGroup = Restrictions.eq(
     458        Hql.property(Item.GROUP.getAlias(), "id"),
     459        Hql.entity(this)
     460      );
     461    Restriction thisQuotaGroup = Restrictions.eq(
     462        Hql.property("qgrp", "id"),
     463        Hql.entity(this)
     464      );
    456465    ItemQuery<User> query = User.getQuery();
    457     query.joinPermanent(Hql.leftJoin("groups", Item.GROUP.getAlias()));
     466    query.joinPermanent(Hql.leftJoin(null, "groups", Item.GROUP.getAlias(), thisGroup, false));
    458467    query.joinPermanent(Hql.leftJoin("quotaGroup", "qgrp"));
    459     query.restrictPermanent(
    460       Restrictions.or(
    461         Restrictions.eq(
    462           Hql.alias("qgrp"),
    463           Hql.entity(this)
    464         ),
    465         Restrictions.eq(
    466           Hql.alias(Item.GROUP.getAlias()),
    467           Hql.entity(this)
    468         )
    469       )
    470     );
     468    query.restrictPermanent(Restrictions.or(thisQuotaGroup, thisGroup));
     469    query.setDistinct(true);
    471470    return query;
    472471  }
Note: See TracChangeset for help on using the changeset viewer.