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

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

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

@Override
public Long getTotalJabatanByParam(JabatanSearchParameter searchParameter) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("costCenter", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan", FetchMode.JOIN);
    criteria.setFetchMode("department", FetchMode.JOIN);
    criteria.setFetchMode("unitKerja", FetchMode.JOIN);
    criteria.setFetchMode("jabatan", FetchMode.JOIN);
    criteria.setFetchMode("paySalaryGrade", FetchMode.JOIN);

    criteria.createAlias("costCenter", "costCenter", JoinType.INNER_JOIN);
    criteria.createAlias("golonganJabatan", "golonganJabatan", JoinType.INNER_JOIN);
    criteria.createAlias("golonganJabatan.pangkat", "pangkat", JoinType.INNER_JOIN);
    criteria.createAlias("department", "department", JoinType.INNER_JOIN);
    criteria.createAlias("unitKerja", "unitKerja", JoinType.INNER_JOIN);
    criteria.createAlias("jabatan", "jabatan", JoinType.INNER_JOIN);
    criteria.createAlias("paySalaryGrade", "paySalaryGrade", JoinType.INNER_JOIN);

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

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

@Override
public List<Jabatan> getJabatanByParentCode(String parentCode) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    /** automatically get relations of department, company 
     *  don't create alias for that entity, or will get error : duplicate association path */
    criteria = this.addJoinRelationsOfCompanyId(criteria, HrmUserInfoUtil.getCompanyId());

    criteria.createAlias("jabatan", "jb", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("jb.code", parentCode));
    criteria.setFetchMode("jabatans", FetchMode.JOIN);
    criteria.setFetchMode("jabatans.jabatan", FetchMode.JOIN);
    criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
    return criteria.list();
}

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

@Override
public Jabatan getJabatanByIdWithDetail(Long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("id", id));
    criteria.setFetchMode("costCenter", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan", FetchMode.JOIN);
    criteria.setFetchMode("department", FetchMode.JOIN);
    criteria.setFetchMode("department.company", FetchMode.JOIN);
    criteria.setFetchMode("unitKerja", FetchMode.JOIN);
    criteria.setFetchMode("jabatan", FetchMode.JOIN);
    return (Jabatan) criteria.uniqueResult();
}

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

@Override
public Jabatan getByIdWithJobDeskripsi(long id) throws Exception {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("id", id));
    criteria.setFetchMode("costCenter", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan", FetchMode.JOIN);
    criteria.setFetchMode("department", FetchMode.JOIN);
    criteria.setFetchMode("unitKerja", FetchMode.JOIN);
    criteria.setFetchMode("jabatan", FetchMode.JOIN);
    criteria.setFetchMode("jabatanDeskripsis", FetchMode.JOIN);
    criteria.setFetchMode("jabatanSpesifikasis", FetchMode.JOIN);
    criteria.setFetchMode("jabatanSpesifikasis.specificationAbility", FetchMode.JOIN);
    return (Jabatan) criteria.uniqueResult();
}

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

@Override
public Jabatan getByIdWithSalaryGrade(long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("id", id));
    criteria.setFetchMode("paySalaryGrade", FetchMode.JOIN);
    return (Jabatan) criteria.uniqueResult();
}

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

@Override
public List<Jabatan> getByName(String name) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    /** automatically get relations of 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.like("name", name, MatchMode.ANYWHERE));
    criteria.addOrder(Order.asc("name"));
    criteria.setFetchMode("department", FetchMode.JOIN);
    criteria.setFirstResult(0);//from  w w w. ja  va  2s.  c om
    criteria.setMaxResults(7);
    return criteria.list();
}

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

@Override
public Jabatan getJabatanByCode(String code) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("code", code));
    criteria.setFetchMode("costCenter", FetchMode.JOIN);
    criteria.setFetchMode("golonganJabatan", FetchMode.JOIN);
    criteria.setFetchMode("department", FetchMode.JOIN);
    criteria.setFetchMode("department.company", FetchMode.JOIN);
    criteria.setFetchMode("unitKerja", FetchMode.JOIN);
    criteria.setFetchMode("jabatan", FetchMode.JOIN);
    return (Jabatan) criteria.uniqueResult();
}

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

@Override
public List<JabatanDeskripsi> getByParam(JabatanDeskripsiSearcParameter searchParameter, int firstResult,
        int maxResults, Order order) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    doSearchByParam(searchParameter, criteria);
    criteria.setFetchMode("jabatan", FetchMode.JOIN);
    criteria.addOrder(order);/*from  w  w w  .  j  av a2 s .com*/
    criteria.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);
    return criteria.list();
}

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

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