Example usage for org.hibernate Criteria setFetchMode

List of usage examples for org.hibernate Criteria setFetchMode

Introduction

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

Prototype

public Criteria setFetchMode(String associationPath, FetchMode mode) throws HibernateException;

Source Link

Document

Specify an association fetching strategy for an association or a collection of values.

Usage

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

@Override
public List<ApprovalDefinitionLoan> getByLoanIdWithDetail(Long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("loanNewSchema", FetchMode.JOIN);
    criteria.setFetchMode("approvalDefinition", FetchMode.JOIN);
    criteria.setFetchMode("approvalDefinition.hrmUserByApproverIndividual", FetchMode.JOIN);
    criteria.setFetchMode("approvalDefinition.hrmUserByOnBehalfIndividual", FetchMode.JOIN);
    criteria.setFetchMode("approvalDefinition.jabatanByApproverPosition", FetchMode.JOIN);
    criteria.setFetchMode("approvalDefinition.jabatanByOnBehalfPosition", FetchMode.JOIN);
    criteria.add(Restrictions.eq("loanNewSchema.id", id));
    return criteria.list();
}

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

@Override
public List<BatchStepExecution> getExitMessageByJobId(Long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("batchJobExecution", "bs", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("bs.jobExecutionId", id));
    criteria.setFetchMode("batchJobExecution", FetchMode.JOIN);
    criteria.setFetchMode("batchJobExecution.batchJobInstance", FetchMode.JOIN);

    return criteria.list();
}

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

@Override
public Long getTotalExitMessageByParam(Long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("batchJobExecution", "bs", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("bs.jobExecutionId", id));
    criteria.setFetchMode("batchJobInstance", FetchMode.JOIN);
    criteria.setFetchMode("batchJobExecution", FetchMode.JOIN);

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

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 w w .  ja v a2  s . c  o  m
    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 BioData getEntityByPKWithDetail(long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("id", id));
    criteria.setFetchMode("city", FetchMode.JOIN);
    criteria.setFetchMode("race", FetchMode.JOIN);
    criteria.setFetchMode("religion", FetchMode.JOIN);
    criteria.setFetchMode("nationality", FetchMode.JOIN);
    criteria.setFetchMode("maritalStatus", FetchMode.JOIN);
    criteria.setFetchMode("dialect", FetchMode.JOIN);
    return (BioData) criteria.uniqueResult();
}

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

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

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

@Override
public List<BioEmergencyContact> getAllDataWithDetailByBioDataId(long bioDataId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("city", FetchMode.JOIN);
    criteria.setFetchMode("familyRelation", FetchMode.JOIN);
    criteria.setFetchMode("bioData", FetchMode.JOIN);
    criteria.add(Restrictions.eq("bioData.id", bioDataId));
    return criteria.list();
}

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

@Override
public BioRelasiPerusahaan getEntityByPkWithDetail(Long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("id", id));
    criteria.setFetchMode("bioData", FetchMode.JOIN);
    criteria.setFetchMode("city", FetchMode.JOIN);
    criteria.setFetchMode("city.province", FetchMode.JOIN);
    criteria.setFetchMode("city.province.country", FetchMode.JOIN);
    return (BioRelasiPerusahaan) criteria.uniqueResult();
}

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

@Override
public List<BioSertifikasi> getAllDataByBioDataId(Long bioDataId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("biodata", FetchMode.JOIN);
    criteria.setFetchMode("educationNonFormal", FetchMode.JOIN);
    criteria.setFetchMode("occupationType", FetchMode.JOIN);
    criteria.add(Restrictions.eq("bioData.id", bioDataId));

    return criteria.list();
}

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

@Override
public BioSertifikasi getEntityByPKWithDetail(Long id) throws Exception {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("educationNonFormal", FetchMode.JOIN);
    criteria.setFetchMode("occupationType", FetchMode.JOIN);
    criteria.add(Restrictions.eq("id", id));
    return (BioSertifikasi) criteria.uniqueResult();
}