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.datacore.dao.impl.IDAOImpl.java

/**
 * get total data count of specific entity
 *
 * @return Long type/*from  w ww  . j  ava2s. c  o  m*/
 */
public Long getTotalData() {
    Long o = (Long) getCurrentSession().createCriteria(getEntityClass()).add(Restrictions.isNotNull("id"))
            .setProjection(Projections.rowCount()).uniqueResult();
    return o;
}

From source file:com.inkubator.datacore.dao.impl.IDAOImpl.java

/**
 * get total data count of specific entity
 *
 * @param active in boolean condition can be true or false
 * @return Long type//from   www  .ja  va 2s .  c o  m
 */
public Long getTotalDataIsActive(Boolean active) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.isNotNull("id"));
    cekIsActive(criteria, active);
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

From source file:com.inkubator.datacore.dao.impl.IDAOImpl.java

/**
 * get total data count of specific entity
 *
 * @param active in Integer condition can be 0 or 1
 * @return Long type/*  w  ww  .  jav a 2s.  com*/
 */
public Long getTotalDataIsActive(Integer active) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.isNotNull("id"));
    cekIsActive(criteria, active);
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

From source file:com.inkubator.datacore.dao.impl.IDAOImpl.java

/**
 * get total data count of specific entity
 *
 * @param active in Byte condition can be -127 or 127
 * @return Long type/*w  w  w .java2s . c o  m*/
 */
public Long getTotalDataIsActive(Byte active) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.isNotNull("id"));
    cekIsActive(criteria, active);
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

From source file:com.inkubator.datacore.dao.impl.IDAOImpl.java

/**
 * Get Total data for specific Entity (T). Note this method only return data
 * that have code/*  w  w  w  .  j  a  v  a2 s  . c o m*/
 *
 *
 * @param code
 * @return total entity
 */
public Long getTotalByCode(String code) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("code", code));
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

From source file:com.inkubator.datacore.dao.impl.IDAOImpl.java

public Long getTotalByCodeAndNotId(String code, Long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("code", code));
    criteria.add(Restrictions.ne("id", id));
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

From source file:com.inkubator.datacore.dao.impl.IDAOImpl.java

public Long getTotalByName(String name) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("name", name));
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

From source file:com.inkubator.datacore.dao.impl.IDAOImpl.java

public Long getTotalByNameAndNotId(String name, Long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("name", name));
    criteria.add(Restrictions.ne("id", id));
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

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

@Override
public Long getTotalAssesorByAppraisalIAndEmpId(Long appraisalId, Long empId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("appraisalProgram", "ap");
    criteria.createAlias("empDataByEmpId", "em");
    criteria.add(Restrictions.eq("ap.id", appraisalId));
    criteria.add(Restrictions.eq("em.id", empId));
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

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

@Override
public Long getTotalApprovalDefinitionByParam(ApprovalDefinitionSearchParameter searchParameter) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    doSearchApprovalDefinitionByParam(searchParameter, criteria);
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}