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

@Override
public List<LoanNewSchemaListOfType> getEntityByLoanNewSchemaWhereStatusActive(Long loanNewSchema) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("loanNewSchema", "loanNewSchema", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("loanNewSchema.id", loanNewSchema));
    criteria.add(Restrictions.eq("isActive", Boolean.TRUE));
    criteria.setFetchMode("loanNewType", FetchMode.JOIN);
    return criteria.list();
}

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

@Override
public LoanNewSchemaListOfType getEntityByLoanNewTypeIdWithDetail(Long loanNewTypeId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("loanNewSchema", FetchMode.JOIN);
    criteria.setFetchMode("loanNewType", FetchMode.JOIN);
    criteria.add(Restrictions.eq("loanNewType.id", loanNewTypeId));
    criteria.add(Restrictions.eq("isActive", Boolean.TRUE));
    return (LoanNewSchemaListOfType) criteria.uniqueResult();
}

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

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

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

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

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

@Override
public MecineFinger getMecineFingerAndDetaiUploadByFK(long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("id", id));
    criteria.setFetchMode("macineFingerUploads", FetchMode.JOIN);
    criteria.setFetchMode("departementUploadCaptures", FetchMode.JOIN);
    return (MecineFinger) criteria.uniqueResult();
}

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

@Override
public Long getTotalEmpInvolveByIdOhsaIncident(Long idOhsaIncident) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("ohsaIncident", FetchMode.JOIN);
    criteria.add(Restrictions.eq("ohsaIncident.id", idOhsaIncident));

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

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

@Override
public List<OhsaEmpInvolve> getListByOhsaIncidentId(Long ohsaIncidentId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("ohsaIncident", FetchMode.JOIN);
    criteria.setFetchMode("empData", FetchMode.JOIN);
    criteria.setFetchMode("empData.bioData", FetchMode.JOIN);
    criteria.setFetchMode("empData.jabatanByJabatanId", FetchMode.JOIN);
    criteria.add(Restrictions.eq("ohsaIncident.id", ohsaIncidentId));
    return criteria.list();
}

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

@Override
public OhsaEmpInvolve getEntityByPKWithDetail(Long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("ohsaIncident", FetchMode.JOIN);
    criteria.setFetchMode("empData", FetchMode.JOIN);
    criteria.setFetchMode("empData.bioData", FetchMode.JOIN);
    criteria.setFetchMode("empData.jabatanByJabatanId", FetchMode.JOIN);
    criteria.add(Restrictions.eq("id", id));
    return (OhsaEmpInvolve) criteria.uniqueResult();
}

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

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

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

@Override
public List<OhsaIncidentDocument> getListByOhsaIncidentId(Long ohsaIncidentId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("ohsaIncident", FetchMode.JOIN);
    criteria.add(Restrictions.eq("ohsaIncident.id", ohsaIncidentId));
    return criteria.list();
}