Example usage for org.hibernate FetchMode JOIN

List of usage examples for org.hibernate FetchMode JOIN

Introduction

In this page you can find the example usage for org.hibernate FetchMode JOIN.

Prototype

FetchMode JOIN

To view the source code for org.hibernate FetchMode JOIN.

Click Source Link

Document

Fetch using an outer join.

Usage

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

@Override
public Divisi getDepartmentNameByDivisiId(Long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("id", id));
    criteria.setFetchMode("department", FetchMode.JOIN);
    return (Divisi) criteria.uniqueResult();
}

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

@Override
public List<EmpCareerHistory> getEmployeeCareerByBioId(long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("bioData", "bio", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("bio.id", id));
    criteria.setFetchMode("jabatan", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan.pangkat", FetchMode.JOIN);
    criteria.setFetchMode("employeeType", FetchMode.JOIN);
    criteria.addOrder(Order.asc("tglPenganngkatan"));
    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);//from   w w  w .j  a v  a 2  s  . co m
    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.EmpCareerHistoryDaoImpl.java

@Override
public EmpCareerHistory getEntityByApprovalActivityNumber(String approvalActivityNumber) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("approvalActivityNumber", approvalActivityNumber));
    criteria.setFetchMode("bioData", FetchMode.JOIN);
    criteria.setFetchMode("copyOfLetterTo", FetchMode.JOIN);
    criteria.setFetchMode("copyOfLetterTo.bioData", FetchMode.JOIN);
    criteria.setFetchMode("employeeType", FetchMode.JOIN);
    criteria.setFetchMode("jabatan", FetchMode.JOIN);
    criteria.setFetchMode("jabatan.department", FetchMode.JOIN);
    criteria.setFetchMode("jabatan.department.company", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan.pangkat", FetchMode.JOIN);
    criteria.setFetchMode("careerTransition", FetchMode.JOIN);
    return (EmpCareerHistory) criteria.uniqueResult();
}

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

@Override
public List<EmpCareerHistory> getPreviousEmpCareerByBioDataIdAndCurrentCreatedOn(Long bioDataId,
        Date currentCreatedOn) {/*  ww w .  j a  v a 2s . c  om*/
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("bioData.id", bioDataId));
    criteria.add(Restrictions.lt("createdOn", currentCreatedOn));
    criteria.addOrder(Order.desc("createdOn"));
    criteria.setFetchMode("copyOfLetterTo", FetchMode.JOIN);
    criteria.setFetchMode("copyOfLetterTo.bioData", FetchMode.JOIN);
    criteria.setFetchMode("employeeType", FetchMode.JOIN);
    criteria.setFetchMode("jabatan", FetchMode.JOIN);
    criteria.setFetchMode("jabatan.department", FetchMode.JOIN);
    criteria.setFetchMode("jabatan.department.company", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan.pangkat", FetchMode.JOIN);
    /*criteria.setMaxResults(1);*/
    return criteria.list();

}

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 www  .  j  av  a 2s.c  om
    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 EmpData getByEmpIdWithDetail(long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("id", id));
    criteria.setFetchMode("jabatanByJabatanId", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanId.department", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanId.department.company", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanId.jabatan", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan", FetchMode.JOIN);
    criteria.setFetchMode("bioData", FetchMode.JOIN);
    criteria.setFetchMode("employeeType", FetchMode.JOIN);
    criteria.setFetchMode("paySalaryGrade", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanId.jabatanDeskripsis", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanId.jabatanSpesifikasis", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanId.jabatanSpesifikasis.specificationAbility", FetchMode.JOIN);
    criteria.setFetchMode("wtGroupWorking", FetchMode.JOIN);
    return (EmpData) criteria.uniqueResult();
}

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

@Override
public EmpData getEmpDataWithBioDataAndMaritalStatusById(long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("id", id));
    criteria.setFetchMode("bioData", FetchMode.JOIN);
    criteria.setFetchMode("bioData.maritalStatus", FetchMode.JOIN);
    criteria.setFetchMode("bioData.city", FetchMode.JOIN);
    return (EmpData) criteria.uniqueResult();
}

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

@Override
public EmpData getByBioDataWithDepartment(long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("bioData.id", id));
    criteria.setFetchMode("bioData", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanGajiId", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanGajiId.department", FetchMode.JOIN);
    return (EmpData) criteria.uniqueResult();
}

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

@Override
public EmpData getByIdWithDetail(long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("id", id));
    criteria.setFetchMode("bioData", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanId", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan.pangkat", FetchMode.JOIN);
    return (EmpData) criteria.uniqueResult();
}