Example usage for org.hibernate Criteria createAlias

List of usage examples for org.hibernate Criteria createAlias

Introduction

In this page you can find the example usage for org.hibernate Criteria createAlias.

Prototype

@Deprecated
public Criteria createAlias(String associationPath, String alias, int joinType) throws HibernateException;

Source Link

Document

Join an association using the specified join-type, assigning an alias to the joined association.

Usage

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

@Override
public List<PaySalaryComponent> getAllDataRenumerationByEmployeeTypeId(Long empTypeId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("modelComponent", "modelComponent", JoinType.INNER_JOIN);
    criteria.createAlias("paySalaryEmpTypes", "paySalaryEmpTypes", JoinType.INNER_JOIN);
    criteria.createAlias("paySalaryEmpTypes.employeeType", "employeeType", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("employeeType.id", empTypeId));

    Disjunction renumerationComp = Restrictions.disjunction();
    renumerationComp.add(Restrictions.eq("modelComponent.spesific", HRMConstant.MODEL_COMP_BENEFIT_TABLE));
    renumerationComp.add(Restrictions.eq("modelComponent.spesific", HRMConstant.MODEL_COMP_BASIC_SALARY));
    criteria.add(renumerationComp);//from   www.  j  a v  a  2 s .c  o  m

    return criteria.list();
}

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

private void doSearchByParam(PayTempKalkulasiSearchParameter parameter, Criteria criteria) {
    criteria.createAlias("paySalaryComponent", "paySalaryComponent", JoinType.INNER_JOIN);
    criteria.createAlias("empData", "empData", JoinType.INNER_JOIN);
    criteria.createAlias("empData.bioData", "bioData", JoinType.INNER_JOIN);
    if (StringUtils.isNotEmpty(parameter.getEmpData())) {
        Disjunction disjunction = Restrictions.disjunction();
        disjunction.add(Restrictions.like("bioData.firstName", parameter.getEmpData(), MatchMode.ANYWHERE));
        disjunction.add(Restrictions.like("bioData.lastName", parameter.getEmpData(), MatchMode.ANYWHERE));
        criteria.add(disjunction);//from  ww  w.j av  a  2  s .c o m
    }
    if (StringUtils.isNotEmpty(parameter.getPaySalaryComponent())) {
        criteria.add(
                Restrictions.like("bioData.firstName", parameter.getPaySalaryComponent(), MatchMode.ANYWHERE));
    }
    criteria.add(Restrictions.isNotNull("id"));
}

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

public void doSearchByParam(String searchParameter, Criteria criteria, Long paySalaryComponentId) {
    criteria.createAlias("paySalaryComponent", "paySalaryComponent", JoinType.INNER_JOIN);
    criteria.createAlias("empData", "empData", JoinType.INNER_JOIN);
    criteria.createAlias("empData.bioData", "bioData", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("paySalaryComponent.id", paySalaryComponentId));
    if (StringUtils.isNotEmpty(searchParameter)) {
        Disjunction disjunction = Restrictions.disjunction();
        disjunction.add(Restrictions.like("empData.nik", searchParameter, MatchMode.START));
        disjunction.add(Restrictions.like("bioData.firstName", searchParameter, MatchMode.START));
        disjunction.add(Restrictions.like("bioData.lastName", searchParameter, MatchMode.START));
        criteria.add(disjunction);//from ww  w.j  a  v a 2s.  c  om
        //            criteria.add(Restrictions.like("bioData.firstName", parameter, MatchMode.ANYWHERE));
    }
    criteria.add(Restrictions.isNotNull("id"));
}

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

@Override
public List<PayTempKalkulasi> getAllDataByEmpDataIdAndTaxNotNull(Long empDataId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("paySalaryComponent", "paySalaryComponent", JoinType.INNER_JOIN);
    criteria.createAlias("paySalaryComponent.taxComponent", "taxComponent", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("empData.id", empDataId));
    criteria.add(Restrictions.isNotNull("paySalaryComponent.taxComponent"));
    criteria.addOrder(Order.desc("taxComponent.id"));
    return criteria.list();
}

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

@Override
public PayTempKalkulasi getEntityByEmpIdAndModelTakeHomePayId(Long empId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("empData", "empData", JoinType.INNER_JOIN);
    criteria.createAlias("paySalaryComponent", "paySalaryComponent", JoinType.INNER_JOIN);
    criteria.createAlias("paySalaryComponent.modelComponent", "modelComponent", JoinType.INNER_JOIN);
    criteria.setFetchMode("empData", FetchMode.JOIN);
    criteria.setFetchMode("empData.bioData", FetchMode.JOIN);
    criteria.setFetchMode("empData.golonganJabatan", FetchMode.JOIN);
    criteria.add(Restrictions.eq("empData.id", empId));
    criteria.add(Restrictions.eq("modelComponent.spesific", HRMConstant.MODEL_COMP_TAKE_HOME_PAY));
    return (PayTempKalkulasi) criteria.uniqueResult();
}

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

@Override
public List<PayTempKalkulasi> getAllDataByEmpDataIdAndExcludeCompTHP(Long empDataId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("paySalaryComponent", "paySalaryComponent", JoinType.INNER_JOIN);
    criteria.createAlias("paySalaryComponent.modelComponent", "modelComponent", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("empData.id", empDataId));
    criteria.add(Restrictions.ne("modelComponent.spesific", HRMConstant.MODEL_COMP_TAKE_HOME_PAY));
    //        criteria.addOrder(Order.asc("modelComponent.spesific"));
    return criteria.list();
}

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

@Override
public PayTempKalkulasi getEntityByEmpDataIdAndSpecificModelComponent(Long empDataId, Integer specific) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("paySalaryComponent", "paySalaryComponent", JoinType.INNER_JOIN);
    criteria.createAlias("paySalaryComponent.modelComponent", "modelComponent", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("empData.id", empDataId));
    criteria.add(Restrictions.eq("modelComponent.spesific", specific));

    return (PayTempKalkulasi) criteria.uniqueResult();
}

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

@Override
public List<PayTempKalkulasi> getAllDataByTotalIncomeBelow(BigDecimal nominal) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("paySalaryComponent", "paySalaryComponent", JoinType.INNER_JOIN);
    criteria.createAlias("paySalaryComponent.modelComponent", "modelComponent", JoinType.INNER_JOIN);
    criteria.setFetchMode("empData", FetchMode.JOIN);
    criteria.add(Restrictions.eq("modelComponent.spesific", HRMConstant.MODEL_COMP_TAKE_HOME_PAY));
    criteria.add(Restrictions.lt("nominal", nominal));
    return criteria.list();
}

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

public void doSearchByParam(String searchParameter, Criteria criteria, Long taxComponentId) {
    criteria.createAlias("taxComponent", "taxComponent", JoinType.INNER_JOIN);
    criteria.createAlias("empData", "empData", JoinType.INNER_JOIN);
    criteria.createAlias("empData.bioData", "bioData", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("taxComponent.id", taxComponentId));
    if (StringUtils.isNotEmpty(searchParameter)) {
        Disjunction disjunction = Restrictions.disjunction();
        disjunction.add(Restrictions.like("empData.nik", searchParameter, MatchMode.ANYWHERE));
        disjunction.add(Restrictions.like("bioData.firstName", searchParameter, MatchMode.ANYWHERE));
        disjunction.add(Restrictions.like("bioData.lastName", searchParameter, MatchMode.ANYWHERE));
        criteria.add(disjunction);/*  w w  w .j  a v a 2 s  .co m*/
        //            criteria.add(Restrictions.like("bioData.firstName", parameter, MatchMode.ANYWHERE));
    }
    criteria.add(Restrictions.isNotNull("id"));
}

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

@Override
public List<PayTempKalkulasiEmpPajak> getAllDataByEmpDataId(Long empDataId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("taxComponent", "taxComponent", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("empData.id", empDataId));
    criteria.addOrder(Order.asc("taxComponent.id"));
    return criteria.list();
}