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

@Override
public List<OverTimeDistribution> getAllDataByIdWithDetail() {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("empData", FetchMode.JOIN);
    criteria.setFetchMode("empData.bioData", FetchMode.JOIN);
    criteria.setFetchMode("wtOverTime", FetchMode.JOIN);
    return criteria.list();
}

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

@Override
public OverTimeDistribution getById(OverTimeDistributionId object) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("id", FetchMode.JOIN);
    criteria.add(Restrictions.eq("id", object));
    return (OverTimeDistribution) criteria.uniqueResult();
}

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

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

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

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

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

@Override
public List<PayReceiverBankAccount> getAllByEmpId(long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("empData", "ep");
    criteria.add(Restrictions.eq("ep.id", id));
    criteria.setFetchMode("bioBankAccount", FetchMode.JOIN);
    criteria.setFetchMode("bioBankAccount.bank", FetchMode.JOIN);
    criteria.setFetchMode("bioBankAccount.bank.bank", FetchMode.JOIN);
    return criteria.list();
}

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

@Override
public List<PayReceiverBankAccount> getAllDataWithDetail() {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("empData", "empData", JoinType.INNER_JOIN);
    criteria.createAlias("empData.bioData", "bioData", JoinType.INNER_JOIN);
    criteria.setFetchMode("bioBankAccount", FetchMode.JOIN);
    criteria.setFetchMode("bioBankAccount.bank", FetchMode.JOIN);
    criteria.addOrder(Order.asc("bioData.firstName"));
    return criteria.list();
}

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

@Override
public List<PaySalaryComponent> getAllDataByParamWithDetail(PaySalaryComponentSearchParameter searchParameter,
        int firstResult, int maxResults, Order order) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("modelComponent", FetchMode.JOIN);
    criteria.setFetchMode("paySalaryJurnal", FetchMode.JOIN);
    criteria.setFetchMode("taxComponent", FetchMode.JOIN);
    doSearchByParam(searchParameter, criteria);
    criteria.addOrder(order);//from w w w  .  j  ava 2s  .co  m
    criteria.setFirstResult(firstResult);
    criteria.setMaxResults(maxResults);
    return criteria.list();
}

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

@Override
public PaySalaryComponent getEntityByPkWithDetail(Long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.setFetchMode("modelComponent", FetchMode.JOIN);
    criteria.setFetchMode("paySalaryJurnal", FetchMode.JOIN);
    criteria.setFetchMode("taxComponent", FetchMode.JOIN);
    ;/*from  w w w  .ja  v  a2 s . com*/
    criteria.add(Restrictions.eq("id", id));
    return (PaySalaryComponent) criteria.uniqueResult();
}

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

@Override
public Long getTotalByModelComponentAndModelReferensi(Long modelComponentId, Integer modelReferensi) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("modelComponent", "modelComponent", JoinType.INNER_JOIN);
    criteria.setFetchMode("modelComponent", FetchMode.JOIN);
    criteria.add(Restrictions.eq("modelComponent.id", modelComponentId));
    criteria.add(Restrictions.eq("modelReffernsil", modelReferensi));
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

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

@Override
public Long getTotalByModelComponentAndModelReferensiAndNotId(Long modelComponentId, Integer modelReferensi,
        Long id) {//from   ww  w  .jav a 2  s .co m
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("modelComponent", "modelComponent", JoinType.INNER_JOIN);
    criteria.setFetchMode("modelComponent", FetchMode.JOIN);
    criteria.add(Restrictions.eq("modelComponent.id", modelComponentId));
    criteria.add(Restrictions.eq("modelReffernsil", modelReferensi));
    criteria.add(Restrictions.ne("id", id));
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}