Example usage for org.hibernate Criteria setFirstResult

List of usage examples for org.hibernate Criteria setFirstResult

Introduction

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

Prototype

public Criteria setFirstResult(int firstResult);

Source Link

Document

Set the first result to be retrieved.

Usage

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

@Override
public List<BatchJobExecution> getByParam(BatchJobExecutionSearchParameter parameter, int firstResult,
        int maxResults, Order orderable) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("batchJobInstance", "batchJobInstance", JoinType.INNER_JOIN);

    if (parameter.getJobName() != null) {

        //            criteria.createAlias("batchJobInstance", "bj", JoinType.INNER_JOIN);
        criteria.add(Restrictions.like("batchJobInstance.jobName", parameter.getJobName(), MatchMode.ANYWHERE));
    }/*w  w w .j a va2 s. c o  m*/
    if (parameter.getStatus() != null) {
        criteria.add(Restrictions.like("BatchJobExecution", parameter.getStatus()));
    }
    criteria.addOrder(orderable);
    criteria.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);
    //criteria.setFetchMode("batchJobInstance", FetchMode.JOIN);
    return criteria.list();
}

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

@Override
public List<BioData> getByParam(BioDataSearchParameter parameter, int firstResult, int maxResults,
        Order orderable) {/*from w  ww  .  ja  v  a2 s.  com*/
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    doSearchBioDataByParam(parameter, criteria);
    criteria.setFetchMode("religion", FetchMode.JOIN);
    criteria.setFetchMode("maritalStatus", FetchMode.JOIN);

    criteria.addOrder(orderable);
    criteria.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);
    return criteria.list();
}

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

@Override
public List<BioData> getByName(String name) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    //        criteria.createAlias("empDatas", "emp",JoinType.INNER_JOIN);
    Disjunction disjunction = Restrictions.disjunction();
    disjunction.add(Restrictions.like("firstName", name, MatchMode.ANYWHERE));
    disjunction.add(Restrictions.like("lastName", name, MatchMode.ANYWHERE));

    criteria.add(disjunction);/* w  w  w . j a  va  2s .  c o  m*/
    criteria.add(Restrictions.isEmpty("empDatas"));
    criteria.addOrder(Order.asc("firstName"));
    criteria.setFirstResult(0);
    criteria.setMaxResults(7);
    return criteria.list();
}

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

@Override
public List<BioPotensiSwot> getByParam(BioPotensiSwotSearchParameter searchParameter, int firstResult,
        int maxResults, Order order) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    doSearchByParam(searchParameter, criteria);
    criteria.addOrder(order);/*  www.  j av a2 s  . c o m*/
    criteria.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);
    return criteria.list();
}

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

@Override
public List<BioRelasiPerusahaan> getByParam(BioRelasiPerusahaanSearchParameter searchParameter, int firstResult,
        int maxResults, Order order) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    doSearchByParam(searchParameter, criteria);
    criteria.addOrder(order);/*from w  w w . j  av  a 2  s . c  o m*/
    criteria.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);
    return criteria.list();
}

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

@Override
public List<CareerTerminationType> getListByParam(CareerTerminationTypeSearchParameter searchParameter,
        int firstResult, int maxResults, Order orderable) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    doSearchTerminationTypeByParam(searchParameter, criteria);
    criteria.addOrder(orderable);/*from w  w  w.  j  av  a 2 s  .c  om*/
    criteria.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);

    return criteria.list();
}

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

@Override
public List<Divisi> getByParam(DivisiSearchParameter searchParameter, int firstResult, int maxResults,
        Order order) {//from   w w  w. j  a  v  a 2s . com
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    doSearchByParam(searchParameter, criteria);
    criteria.addOrder(order);
    criteria.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);
    //criteria.setFetchMode("department", FetchMode.JOIN);
    criteria.createAlias("department", "department", JoinType.INNER_JOIN);
    return criteria.list();
}

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

@Override
public List<EmpCareerHistory> getByParamReport(ReportEmpMutationParameter searchParameter, int firstResult,
        int maxResults, Order order) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN);
    criteria.createAlias("jabatan", "jabatan", JoinType.INNER_JOIN);
    doSearchEmpRotasiByParamReport(searchParameter, criteria);

    DetachedCriteria maxTglPengangkatanQuery = DetachedCriteria.forClass(getEntityClass());
    ProjectionList proj = Projections.projectionList();
    proj.add(Projections.max("tglPenganngkatan"));
    proj.add(Projections.groupProperty("nik"));
    maxTglPengangkatanQuery.setProjection(proj);

    criteria.add(Subqueries.propertiesIn(new String[] { "tglPenganngkatan", "nik" }, maxTglPengangkatanQuery));
    criteria.addOrder(order);/* w  w  w.j  a  va2 s .c  om*/
    criteria.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);

    List<EmpCareerHistory> listEmpCareerHistorys = criteria.list();

    //Set Jabatan Lama/sebelumnya dari masing - masing record
    for (EmpCareerHistory ech : listEmpCareerHistorys) {
        Criteria criteriaOldPosition = getCurrentSession().createCriteria(getEntityClass());
        criteriaOldPosition.setFetchMode("jabatan", FetchMode.JOIN);
        criteriaOldPosition.add(Restrictions.eq("nik", ech.getNik()));
        criteriaOldPosition.add(Restrictions.lt("tglPenganngkatan", ech.getTglPenganngkatan()));
        criteriaOldPosition.addOrder(Order.desc("tglPenganngkatan"));
        criteriaOldPosition.setMaxResults(1);
        EmpCareerHistory prevPosition = (EmpCareerHistory) criteriaOldPosition.uniqueResult();

        //jika sebelumnya dia sudah pernah menjabat di posisi lain maka set oldJabatan dengan posisi tersebut
        if (null != prevPosition) {
            ech.setJabatanOldCode(prevPosition.getJabatan().getCode());
            ech.setJabatanOldName(prevPosition.getJabatan().getName());
        } else {
            ech.setJabatanOldCode("-");
        }
    }

    return listEmpCareerHistorys;
}

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

@Override
public List<EmpData> getAllDataByParam(Long companyId, EmpDataSearchParameter searchParameter, int firstResult,
        int maxResults, Order order) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    doSearchByParam(companyId, searchParameter, criteria);
    criteria.addOrder(order);/*from w ww. j  ava  2  s.c o  m*/
    criteria.createAlias("golonganJabatan", "golonganJabatan", JoinType.LEFT_OUTER_JOIN);
    //        criteria.createAlias("bioData", "bioData", JoinType.LEFT_OUTER_JOIN);

    //        criteria.createAlias("jabatanByJabatanId", "bioData", JoinType.LEFT_OUTER_JOIN);
    criteria.createAlias("taxFree", "taxFree", JoinType.INNER_JOIN);
    //        criteria.setFetchMode("bioData", FetchMode.JOIN);
    criteria.setFetchMode("bioData.city", FetchMode.JOIN);
    criteria.setFetchMode("bioData.maritalStatus", FetchMode.JOIN);
    //        criteria.setFetchMode("jabatanByJabatanId", FetchMode.JOIN);
    //        criteria.setFetchMode("golonganJabatan", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan.pangkat", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanId.department", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanId.unitKerja", FetchMode.JOIN);
    criteria.setFetchMode("wtGroupWorking", FetchMode.JOIN);
    //        criteria.setFetchMode("taxFree", FetchMode.JOIN);
    criteria.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);
    return criteria.list();
}

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

@Override
public List<EmpData> getAllDataNotExistInUserByParam(String param, int firstResult, int maxResults,
        Order order) {//www.  ja va2 s  .  c o m
    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);

    criteria.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);
    criteria.addOrder(order);

    return criteria.list();
}