Example usage for org.hibernate Criteria setProjection

List of usage examples for org.hibernate Criteria setProjection

Introduction

In this page you can find the example usage for org.hibernate Criteria setProjection.

Prototype

public Criteria setProjection(Projection projection);

Source Link

Document

Used to specify that the query results will be a projection (scalar in nature).

Usage

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

public long getArkRoleModuleFunctionVOCount(ArkRoleModuleFunctionVO arkRoleModuleFunctionVoCriteria) {
    Criteria criteria = buildArkRoleModuleFunctionVoCriteria(arkRoleModuleFunctionVoCriteria);
    criteria.setProjection(Projections.rowCount());
    Long totalCount = (Long) criteria.uniqueResult();
    return totalCount;
}

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

protected Criteria buildArkRoleModuleFunctionVoCriteria(
        ArkRoleModuleFunctionVO arkRoleModuleFunctionVoCriteria) {
    Criteria criteria = getSession().createCriteria(ArkRolePolicyTemplate.class, "arpt");

    if (arkRoleModuleFunctionVoCriteria.getArkRole() != null) {
        criteria.add(Restrictions.eq("arpt.arkRole", arkRoleModuleFunctionVoCriteria.getArkRole()));
    }/*  w w w .  ja v  a 2s.c  o  m*/

    if (arkRoleModuleFunctionVoCriteria.getArkModule() != null) {
        criteria.add(Restrictions.eq("arpt.arkModule", arkRoleModuleFunctionVoCriteria.getArkModule()));
    }

    if (arkRoleModuleFunctionVoCriteria.getArkFunction() != null) {
        criteria.add(Restrictions.eq("arpt.arkFunction", arkRoleModuleFunctionVoCriteria.getArkFunction()));
    }

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("arpt.arkRole"), "arkRole");
    projectionList.add(Projections.groupProperty("arpt.arkModule"), "arkModule");
    projectionList.add(Projections.groupProperty("arpt.arkFunction"), "arkFunction");

    criteria.setProjection(projectionList);

    ResultTransformer resultTransformer = Transformers.aliasToBean(ArkRoleModuleFunctionVO.class);
    criteria.setResultTransformer(resultTransformer);

    return criteria;
}

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

public List<ArkRoleModuleFunctionVO> getArkRoleModuleFunctionVoList(ArkRole arkRole) {
    Criteria criteria = getSession().createCriteria(ArkRolePolicyTemplate.class, "arpt");
    criteria.add(Restrictions.eq("arpt.arkRole", arkRole));

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("arpt.arkRole"), "arkRole");
    projectionList.add(Projections.groupProperty("arpt.arkModule"), "arkModule");
    projectionList.add(Projections.groupProperty("arpt.arkFunction"), "arkFunction");

    criteria.setProjection(projectionList);

    ResultTransformer resultTransformer = Transformers.aliasToBean(ArkRoleModuleFunctionVO.class);
    criteria.setResultTransformer(resultTransformer);

    return criteria.list();
}

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

public List<ArkModule> getArkModuleList(ArkRole arkRole) {
    Criteria criteria = getSession().createCriteria(ArkModuleRole.class);

    if (arkRole != null) {
        criteria.add(Restrictions.eq("arkRole", arkRole));
    }//from  w  w w  .j av a 2  s.  c  o m
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("arkModule"), "arkModule");
    criteria.setProjection(projectionList);

    return criteria.list();
}

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

public long getArkModuleFunctionCount(ArkModuleFunction arkModuleFunctionCriteria) {
    Criteria criteria = buildArkModuleFunctionCriteria(arkModuleFunctionCriteria);
    criteria.setProjection(Projections.rowCount());
    Long totalCount = (Long) criteria.uniqueResult();
    return totalCount;
}

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

public List<ArkFunction> getArkFunctionListByArkModule(ArkModule arkModule) {
    Criteria criteria = getSession().createCriteria(ArkModuleFunction.class);
    if (arkModule.getId() != null) {
        criteria.add(Restrictions.eq("arkModule", arkModule));
    }/* www .j  av  a  2  s .  co m*/
    criteria.createAlias("arkModule", "module");
    criteria.addOrder(Order.asc("module.name"));
    criteria.addOrder(Order.asc("functionSequence"));

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("arkFunction"), "arkFunction");
    criteria.setProjection(projectionList);
    return criteria.list();
}

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

public long getArkRoleCount(ArkRole arkRoleCriteria) {
    Criteria criteria = buildArkRoleCriteria(arkRoleCriteria);
    criteria.setProjection(Projections.rowCount());
    Long totalCount = (Long) criteria.uniqueResult();
    return totalCount;
}

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

public List<ArkModule> getArkModuleListByArkRole(ArkRole arkRole) {
    Criteria criteria = getSession().createCriteria(ArkModuleRole.class);
    if (arkRole != null) {
        criteria.add(Restrictions.eq("arkRole", arkRole));
    }//www . ja va2  s .co  m
    criteria.createAlias("arkModule", "module");
    criteria.addOrder(Order.asc("module.name"));

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("arkModule"), "arkModule");
    criteria.setProjection(projectionList);
    return criteria.list();
}

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

public long getArkModuleRoleCount(ArkModuleRole arkModuleRoleCriteria) {
    Criteria criteria = buildArkModuleRoleCriteria(arkModuleRoleCriteria);
    criteria.setProjection(Projections.rowCount());
    Long totalCount = (Long) criteria.uniqueResult();
    return totalCount;
}

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

public List<ArkRole> getArkRoleListByArkModule(ArkModule arkModule) {
    Criteria criteria = getSession().createCriteria(ArkModuleRole.class);
    if (arkModule.getId() != null) {
        criteria.add(Restrictions.eq("arkModule", arkModule));
    }//from   ww  w.  j  av a 2s  .c  o m

    // Restrict searching/selecting of Super Administrator
    criteria.add(Restrictions.ne("arkModule",
            getArkRoleByName(au.org.theark.core.security.RoleConstants.ARK_ROLE_SUPER_ADMINISTATOR)));

    criteria.createAlias("arkRole", "role");
    criteria.addOrder(Order.asc("role.name"));

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("arkRole"), "arkRole");
    criteria.setProjection(projectionList);
    return criteria.list();
}