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.EmpDataDaoImpl.java

@Override
public List<EmpData> getEmpDataByListId(List<Long> data) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.in("id", data));
    criteria.setFetchMode("jabatanByJabatanGajiId", FetchMode.JOIN);
    criteria.setFetchMode("bioData", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanGajiId.department", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanGajiId.unitKerja", FetchMode.JOIN);
    return criteria.list();
}

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

@Override
public EmpData getEmpDataWithBiodata(Long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("id", id));
    criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN);
    criteria.createAlias("bioData.maritalStatus", "maritalStatus", JoinType.INNER_JOIN);
    criteria.setFetchMode("bioData", FetchMode.JOIN);
    criteria.setFetchMode("maritalStatus", FetchMode.JOIN);
    return (EmpData) criteria.uniqueResult();
}

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

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

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

@Override
public EmpData getByEmpDataByBioDataId(long bioDataid) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN);
    criteria.setFetchMode("bioData", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanId", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanId.department", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanId.department.company", FetchMode.JOIN);
    criteria.setFetchMode("employeeType", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan.pangkat", FetchMode.JOIN);
    criteria.add(Restrictions.eq("bioData.id", bioDataid));
    return (EmpData) criteria.uniqueResult();
}

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

@Override
public List<EmpData> getAllDataByEmployeeTypeOrGolonganJabatanOrUnitKerja(List<Long> empTypeId,
        List<Long> golJabId, List<Long> unitKerjaId, int firstResult, int maxResults, Order order) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    /**//www  . 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.not(Restrictions.eq("status", HRMConstant.EMP_TERMINATION)));

    criteria.createAlias("jabatanByJabatanId.unitKerja", "unitKerja", JoinType.LEFT_OUTER_JOIN);
    criteria.createAlias("jabatanByJabatanId.golonganJabatan", "goljab", JoinType.LEFT_OUTER_JOIN);
    //        criteria.createAlias("department.company", "company", JoinType.LEFT_OUTER_JOIN);
    criteria.createAlias("employeeType", "employeeType", JoinType.LEFT_OUTER_JOIN);
    criteria.setFetchMode("bioData", FetchMode.JOIN);
    if (!empTypeId.isEmpty()) {
        criteria.add(Restrictions.in("employeeType.id", empTypeId));
    }
    if (!golJabId.isEmpty()) {
        criteria.add(Restrictions.in("goljab.id", golJabId));
    }
    if (!unitKerjaId.isEmpty()) {
        criteria.add(Restrictions.in("unitKerja.id", unitKerjaId));
    }
    criteria.addOrder(order);
    criteria.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);
    return criteria.list();
}

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

@Override
public Boolean isEmpDataWithNullWtGroupWorkingExist() {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("wtGroupWorking", FetchMode.JOIN);
    criteria.add(Restrictions.isNull("wtGroupWorking"));
    criteria.add(Restrictions.not(Restrictions.eq("status", HRMConstant.EMP_TERMINATION)));

    return !criteria.list().isEmpty();
}

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

@Override
public List<EmpData> getAllDataByParam(EmpDataSearchParameter searchParameter, int firstResult, int maxResults,
        Order order) {/*from ww  w . jav a  2  s .  c  om*/
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("golonganJabatan", "golonganJabatan", JoinType.LEFT_OUTER_JOIN);
    //        criteria.createAlias("taxFree", "taxFree", JoinType.INNER_JOIN);
    criteria.setFetchMode("bioData.city", FetchMode.JOIN);
    criteria.setFetchMode("bioData.maritalStatus", 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);
    doSearchByParam(searchParameter, criteria);
    criteria.addOrder(order);
    criteria.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);
    return criteria.list();
}

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

@Override
public List<EmpData> getAllDataByParamForOnlyEmployee(Long companyId, EmpDataSearchParameter searchParameter,
        int firstResult, int maxResults, Order order) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    doSearchByParamOnlyEmployee(companyId, searchParameter, criteria);
    criteria.addOrder(order);/*from w w w. j  ava2s.  c om*/
    criteria.createAlias("golonganJabatan", "golonganJabatan", JoinType.LEFT_OUTER_JOIN);
    //        criteria.createAlias("taxFree", "taxFree", JoinType.INNER_JOIN);
    criteria.setFetchMode("bioData.city", FetchMode.JOIN);
    criteria.setFetchMode("bioData.maritalStatus", 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.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);
    return criteria.list();
}

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

@Override
public List<EmpData> getAllDataByParamForOnlyEmployeeNotIncludeCompany(EmpDataSearchParameter searchParameter,
        int firstResult, int maxResults, Order order) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    doSearchByParamOnlyEmployeeNotIncludeCompany(searchParameter, criteria);
    criteria.addOrder(order);//ww w . j  a v a 2  s. c  o m
    //        criteria.createAlias("golonganJabatan", "golonganJabatan", JoinType.LEFT_OUTER_JOIN);

    criteria.setFetchMode("bioData.city", FetchMode.JOIN);
    criteria.setFetchMode("bioData.maritalStatus", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan.pangkat", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanId", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanId.department", FetchMode.JOIN);
    criteria.setFetchMode("jabatanByJabatanId.unitKerja", FetchMode.JOIN);
    criteria.setFetchMode("taxFree", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan", FetchMode.JOIN);
    //        criteria.setFetchMode("wtGroupWorking", 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> getAllByJabatanAndCompanyAndStatus(long jabataId, String status) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("bioData", "bi", JoinType.INNER_JOIN);
    criteria.createAlias("jabatanByJabatanId", "jb", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("jb.id", jabataId));
    criteria.add(Restrictions.not(Restrictions.eq("status", status)));
    criteria.setFetchMode("bioData", FetchMode.JOIN);
    criteria.addOrder(Order.asc("bi.firstName"));
    return criteria.list();
}