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> getListEmpDataWhichNotExistOnFingerEmpMatch() {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());

    DetachedCriteria fingerMatchEmpCriteria = DetachedCriteria.forClass(FingerMatchEmp.class)
            .createAlias("empData", "empData", JoinType.INNER_JOIN)
            .setProjection(Projections.property("empData.id"));

    String[] propertyEmpDataId = { "id" };
    criteria.add(Subqueries.propertiesNotIn(propertyEmpDataId, fingerMatchEmpCriteria))
            .setFetchMode("bioData", FetchMode.JOIN).setFetchMode("jabatanByJabatanId", FetchMode.JOIN);
    return criteria.list();
}

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

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

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

@Override
public List<GolonganJabatan> getAllWithDetail() {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("pangkat", FetchMode.JOIN);
    criteria.addOrder(Order.asc("code"));
    return criteria.list();
}

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

@Override
public GolonganJabatan getEntityWithDetailById(Long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("pangkat", FetchMode.JOIN);
    criteria.setFetchMode("paySalaryGrade", FetchMode.JOIN);
    criteria.add(Restrictions.eq("id", id));
    return (GolonganJabatan) criteria.uniqueResult();
}

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

@Override
public HrmRole getEntityByPkWithMenus(long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("id", id));
    criteria.setFetchMode("hrmMenuRoles", FetchMode.JOIN);
    criteria.setFetchMode("hrmMenuRoles.hrmMenu", FetchMode.JOIN);
    return (HrmRole) criteria.uniqueResult();
}

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

@Override
public HrmUser getByUserIdOrEmail(String param) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    Disjunction disjunction = Restrictions.disjunction();
    disjunction.add(Restrictions.eq("userId", param));
    disjunction.add(Restrictions.eq("emailAddress", param));
    criteria.add(disjunction);//  ww  w .  j  av a  2  s.  c om

    criteria.setFetchMode("empData", FetchMode.JOIN);
    criteria.setFetchMode("empData.bioData", FetchMode.JOIN);
    return (HrmUser) criteria.uniqueResult();
}

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

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

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

@Override
public HrmUser getUserWithDetailByUserId(String userId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("userId", userId));
    ;/*from  w  w  w.j a  v  a 2  s .co  m*/
    criteria.setFetchMode("empData", FetchMode.JOIN);
    criteria.setFetchMode("empData.bioData", FetchMode.JOIN);
    return (HrmUser) criteria.uniqueResult();
}

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

@Override
public List<HrmUserRole> getByUserId(long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("hrmUser", "su");
    criteria.add(Restrictions.eq("su.id", id));
    criteria.addOrder(Order.desc("hrmRole"));
    criteria.setFetchMode("hrmRole", FetchMode.JOIN);
    return criteria.list();
}

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

@Override
public List<Insurance> getByParam(InsuranceSearchParameter parameter, int firstResult, int maxResults,
        Order orderable) {/*from   w ww.j ava 2 s  . co m*/
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("city", FetchMode.JOIN);
    criteria.setFetchMode("city.province", FetchMode.JOIN);
    criteria.setFetchMode("city.province.country", FetchMode.JOIN);
    doSearchByParam(parameter, criteria);
    criteria.addOrder(orderable);
    criteria.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);
    return criteria.list();
}