public int countBGParticipantsOfBGContext(BGContext bgContext) {
DB db = DBFactory.getInstance();
String q = "select count(distinct id) from org.olat.basesecurity.IdentityImpl id"
+ ", org.olat.basesecurity.SecurityGroupMembershipImpl sgm" + ", org.olat.group.BusinessGroupImpl bg"
+ " where bg.groupContext = :context" + " and bg.partipiciantGroup = sgm.securityGroup" + " and sgm.identity = id";
DBQuery query = db.createQuery(q);
query.setEntity("context", bgContext);
List resultList = query.list();
int result = 0;
// if no join/group by matches, result list size is 0 and count undefined ->
// result is 0
if (resultList.size() > 0) {
Object obj = resultList.get(0);