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

@Override
public List<OrgTypeOfSpecList> getOrgTypeOfSpecList(long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("orgTypeOfSpec", "op", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("op.id", id));
    return criteria.list();
}

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

private void doSearch(OverTimeDistributionSearchParameter searchParameter, Criteria criteria) {
    criteria.createAlias("empData", "empData", JoinType.INNER_JOIN);
    criteria.createAlias("empData.bioData", "bioData", JoinType.INNER_JOIN);
    criteria.createAlias("wtOverTime", "wtOverTime", JoinType.INNER_JOIN);
    if (searchParameter.getEmpData() != null) {

        //            Disjunction disjunction = Restrictions.disjunction();
        //            disjunction.add(Restrictions.like("bioData.firstName", searchParameter.getEmpData(), MatchMode.START));
        //            disjunction.add(Restrictions.like("bioData.lastName", searchParameter.getEmpData(), MatchMode.START));
        //            criteria.add(disjunction);
        criteria.add(Restrictions.ilike("bioData.combineName", searchParameter.getEmpData().toLowerCase(),
                MatchMode.ANYWHERE));//from  ww w .  jav a 2 s . c  om
    }
    if (searchParameter.getNik() != null) {
        criteria.add(Restrictions.like("empData.nik", searchParameter.getNik(), MatchMode.START));
    }
    if (StringUtils.isNotEmpty(searchParameter.getWtOverTime())) {

        criteria.add(Restrictions.like("wtOverTime.name", searchParameter.getWtOverTime(), MatchMode.ANYWHERE));
    }
    criteria.add(Restrictions.isNotNull("id"));
}

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

@Override
public List<OverTimeDistribution> getAllDataByEmpDataIdAndIsActive(Long empDataId, Boolean isActive) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.add(Restrictions.eq("empData.id", empDataId));
    criteria.createAlias("wtOverTime", "wtOverTime", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("wtOverTime.isActive", isActive));
    return criteria.list();
}

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

private void doSearchByParam(PayComponentDataExceptionSearchParameter searchParameter, Criteria criteria) {
    if (searchParameter.getPaySalaryComponent() != null) {
        criteria.createAlias("paySalaryComponent", "paySalaryComponent", JoinType.INNER_JOIN);
        criteria.add(Restrictions.like("paySalaryComponent.name", searchParameter.getPaySalaryComponent(),
                MatchMode.START));/*from  w ww.j  a  v a  2 s . com*/
    }
    criteria.add(Restrictions.isNotNull("id"));
}

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

private void doSearchByParamForDetail(String searchParameter, Criteria criteria) {
    criteria.createAlias("empData", "empData", JoinType.INNER_JOIN);
    criteria.createAlias("empData.bioData", "bioData", JoinType.INNER_JOIN);
    criteria.createAlias("paySalaryComponent", "paySalaryComponent", JoinType.INNER_JOIN);
    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   w ww .  j  ava 2  s. co  m*/
    }
    criteria.add(Restrictions.isNotNull("id"));
}

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

@Override
public Long getDuplicateEmpData(Long empDataId, Long paySalaryComponentId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("empData", "empData", JoinType.INNER_JOIN);
    criteria.createAlias("paySalaryComponent", "paySalaryComponent", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("empData.id", empDataId));
    criteria.add(Restrictions.eq("paySalaryComponent.id", paySalaryComponentId));
    return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
}

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 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) {/*  w ww.j a  va  2  s  .c  o 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();
}

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

@Override
public PaySalaryComponent getEntityBySpecificModelComponent(Integer specific) {
    PaySalaryComponent paySalaryComponent = null;

    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("modelComponent", "modelComponent", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("modelComponent.spesific", specific));
    criteria.addOrder(Order.desc("createdOn"));
    criteria.setFirstResult(0);/*www .j a  v a2  s . co  m*/
    criteria.setMaxResults(1);

    if (!criteria.list().isEmpty()) {
        paySalaryComponent = (PaySalaryComponent) criteria.list().get(0);
    }

    return paySalaryComponent;
}