Example usage for org.hibernate.criterion Projections rowCount

List of usage examples for org.hibernate.criterion Projections rowCount

Introduction

In this page you can find the example usage for org.hibernate.criterion Projections rowCount.

Prototype

public static Projection rowCount() 

Source Link

Document

The query row count, ie.

Usage

From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java

@Override
public Long getTotalByAgeBetween(Date startDate, Date endDate) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    /**/*from  ww  w .j a  v a 2s . c o m*/
     * automatically get relations of jabatanByJabatanId, department,
     * company don't create alias for that entity, or will get error :
     * duplicate association path
     */
    criteria = this.addJoinRelationsOfCompanyId(criteria, HrmUserInfoUtil.getCompanyId());
    criteria.add(Restrictions.neOrIsNotNull("status", HRMConstant.EMP_TERMINATION));

    criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN);
    criteria.add(Restrictions.gt("bioData.dateOfBirth", startDate));
    criteria.add(Restrictions.lt("bioData.dateOfBirth", endDate));
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java

@Override
public Long getTotalByAgeLessThan(Date date) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    /**/*from   w w  w. j av a 2s .  c  om*/
     * automatically get relations of jabatanByJabatanId, department,
     * company don't create alias for that entity, or will get error :
     * duplicate association path
     */
    criteria = this.addJoinRelationsOfCompanyId(criteria, HrmUserInfoUtil.getCompanyId());
    criteria.add(Restrictions.neOrIsNotNull("status", HRMConstant.EMP_TERMINATION));

    criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN);
    criteria.add(Restrictions.lt("bioData.dateOfBirth", date));
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java

@Override
public Long getTotalByAgeMoreThan(Date date) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    /**/*from  ww  w . j av  a  2s  .  c  o  m*/
     * automatically get relations of jabatanByJabatanId, department,
     * company don't create alias for that entity, or will get error :
     * duplicate association path
     */
    criteria = this.addJoinRelationsOfCompanyId(criteria, HrmUserInfoUtil.getCompanyId());
    criteria.add(Restrictions.neOrIsNotNull("status", HRMConstant.EMP_TERMINATION));

    criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN);
    criteria.add(Restrictions.gt("bioData.dateOfBirth", date));
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java

@Override
public Long getTotalByDepartmentId(Long departmentId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    /**//  ww w  . j  a v  a2 s .  c  om
     * automatically get relations of jabatanByJabatanId, department,
     * company don't create alias for that entity, or will get error :
     * duplicate association path
     */
    criteria = this.addJoinRelationsOfCompanyId(criteria, HrmUserInfoUtil.getCompanyId());
    criteria.add(Restrictions.neOrIsNotNull("status", HRMConstant.EMP_TERMINATION));

    criteria.add(Restrictions.eq("department.id", departmentId));
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java

@Override
public Long getTotalByParam(Long companyId, EmpDataSearchParameter searchParameter) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    doSearchByParam(companyId, searchParameter, criteria);
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java

@Override
public Long getTotalByNikandNotId(String nik, Long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    /**//from  w w w  .j a va  2s  .c om
     * automatically get relations of jabatanByJabatanId, department,
     * company don't create alias for that entity, or will get error :
     * duplicate association path
     */
    criteria = this.addJoinRelationsOfCompanyId(criteria, HrmUserInfoUtil.getCompanyId());

    criteria.add(Restrictions.eq("nik", nik));
    criteria.add(Restrictions.ne("id", id));
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java

@Override
public Long getTotalByNIK(String nik) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    /**/* w  w w .  java2s .c  om*/
     * automatically get relations of jabatanByJabatanId, department,
     * company don't create alias for that entity, or will get error :
     * duplicate association path
     */
    criteria = this.addJoinRelationsOfCompanyId(criteria, HrmUserInfoUtil.getCompanyId());

    criteria.add(Restrictions.eq("nik", nik));
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java

@Override
public Long getTotalNotExistInUserByParam(String param) {
    DetachedCriteria subQuery = DetachedCriteria.forClass(HrmUser.class, "user")
            .setProjection(Projections.property("user.id"));
    subQuery.add(Property.forName("employee.id").eqProperty("user.empData.id"));

    Criteria criteria = getCurrentSession().createCriteria(getEntityClass(), "employee");
    criteria.add(Subqueries.notExists(subQuery));
    criteria = this.doSearchNotExistInUserByParam(param, criteria);

    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java

@Override
public Long getTotalReportEmpWorkingGroupByParam(ReportEmpWorkingGroupParameter param) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    doSearchReportEmpWorkingGroupByParam(param, criteria);
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java

@Override
public Long getTotalReportEmpDepartmentJabatanByParam(ReportEmpDepartmentJabatanParameter param) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("golonganJabatan", "goljab", JoinType.INNER_JOIN);
    doSearchReportEmpDepartmentJabatanByParam(param, criteria);
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}