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

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

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

@Override
public List<OrgKlasifikasiJobFamily> getByKlasifikasiId(long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("klasifikasiKerja", "kk");
    criteria.add(Restrictions.eq("kk.id", id));
    criteria.addOrder(Order.desc("golonganJabatan"));
    criteria.setFetchMode("golonganJabatan", FetchMode.JOIN);
    return criteria.list();
}

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

@Override
public List<OrgTypeOfSpecJabatan> getAllDataByJabatanId(Long id, int firstResult, int maxResults, Order order) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("jabatan.id", id));
    criteria.setFetchMode("jabatan", FetchMode.JOIN);
    criteria.setFetchMode("orgTypeOfSpecList", FetchMode.JOIN);

    criteria.createAlias("jabatan", "jabatan", JoinType.INNER_JOIN);
    criteria.createAlias("orgTypeOfSpecList", "orgTypeOfSpecList", JoinType.INNER_JOIN);

    criteria.addOrder(order);//from  ww  w.j  a v  a  2s .  c om
    criteria.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);
    return criteria.list();
}

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

@Override
public OrgTypeOfSpecJabatan getEntityByPK(OrgTypeOfSpecJabatanId id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("id", id));
    criteria.setFetchMode("orgTypeOfSpecList", FetchMode.JOIN);
    return (OrgTypeOfSpecJabatan) criteria.uniqueResult();
}

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

@Override
public List<OrgTypeOfSpecJabatan> getAllDataByJabatanId(Long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("jabatan.id", id));
    criteria.setFetchMode("jabatan", FetchMode.JOIN);
    criteria.setFetchMode("orgTypeOfSpecList", FetchMode.JOIN);

    criteria.createAlias("jabatan", "jabatan", JoinType.INNER_JOIN);
    criteria.createAlias("orgTypeOfSpecList", "orgTypeOfSpecList", JoinType.INNER_JOIN);

    return criteria.list();
}

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

@Override
public List<OrgTypeOfSpecList> getByParam(OrgTypeOfSpecListSearchParameter searchParameter, int firstResult,
        int maxResults, Order order) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    doSearchByParam(searchParameter, criteria);
    criteria.addOrder(order);//  w  w  w . java 2  s  .  c o  m
    criteria.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);
    criteria.setFetchMode("orgTypeOfSpec", FetchMode.JOIN);
    criteria.createAlias("orgTypeOfSpec", "orgTypeOfSpec", JoinType.INNER_JOIN);
    return criteria.list();
}

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

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

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

@Override
public List<OrgTypeOfSpecList> getAllDataByOrgTypeOfSpecIdAndOrderByCode(Long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("orgTypeOfSpec.id", id));
    criteria.setFetchMode("orgTypeOfSpec", FetchMode.JOIN);
    criteria.addOrder(Order.asc("code"));
    return criteria.list();
}

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

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

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

@Override
public OverTimeDistribution getEntityByParamWithDetail(Long empId, Long overTimeId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("empData", FetchMode.JOIN);
    criteria.setFetchMode("empData.bioData", FetchMode.JOIN);
    criteria.setFetchMode("wtOverTime", FetchMode.JOIN);
    criteria.add(Restrictions.eq("empData.id", empId));
    criteria.add(Restrictions.eq("wtOverTime.id", overTimeId));
    return (OverTimeDistribution) criteria.uniqueResult();
}