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

public Criteria createAlias(String associationPath, String alias) throws HibernateException;

Source Link

Document

Join an association, assigning an alias to the joined association.

Usage

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

@Override
public List<JabatanDeskripsi> getAllDataByJabatanId(Long jabatanId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("jabatan", "jb");
    criteria.add(Restrictions.eq("jb.id", jabatanId));
    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();
}

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

@Override
public List<LoanNewSchemaListOfType> getAllDataByLoanSchemaId(Long loanSchemaId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("loanNewSchema", "lns");
    criteria.add(Restrictions.eq("lns.id", loanSchemaId));
    criteria.addOrder(Order.desc("loanNewType"));
    criteria.setFetchMode("loanNewType", FetchMode.JOIN);
    return criteria.list();
}

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

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

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

@Override
public PayComponentDataException getByEmpIdAndComponentId(Long empId, Long paySalaryCompId) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("empData", "emp");
    criteria.createAlias("paySalaryComponent", "payComp");
    criteria.add(Restrictions.eq("emp.id", empId));
    criteria.add(Restrictions.eq("payComp.id", paySalaryCompId));
    return (PayComponentDataException) criteria.uniqueResult();

}

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

@Override
public List<PayComponentDataException> getAllByEmpId(Long id) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("empData", "emp");
    criteria.add(Restrictions.eq("emp.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.PaySalaryComponentDaoImpl.java

private void doSearchComponentUploadByParam(PaySalaryComponentSearchParameter searchParameter,
        Criteria criteria) {
    if (StringUtils.isNotEmpty(searchParameter.getName())) {
        criteria.add(Restrictions.like("name", searchParameter.getName(), MatchMode.ANYWHERE));
    }//from w  w w.  jav  a 2s  . co  m
    if (StringUtils.isNotEmpty(searchParameter.getCode())) {
        criteria.add(Restrictions.like("code", searchParameter.getCode(), MatchMode.START));
    }
    criteria.add(Restrictions.isNotNull("id"));
    criteria.createAlias("modelComponent", "modelComponent");
    criteria.add(Restrictions.eq("modelComponent.spesific", HRMConstant.MODEL_COMP_UPLOAD));
}

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

@Override
public PaySalaryComponent getByEmployeeTypeIdAndComponentIdAndJoinDate(Long typeId, Long componentId,
        Date joinDate) {/*from   w  w  w.j a  v a 2 s. c  o  m*/
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("paySalaryEmpTypes", "payType");
    criteria.createAlias("payType.employeeType", "employeeType");
    criteria.add(Restrictions.eq("id", componentId));
    criteria.add(Restrictions.eq("employeeType.id", typeId));
    int timeTmb = 0;
    try {
        timeTmb = DateTimeUtil.getTotalDay(joinDate, new Date());
    } catch (Exception ex) {
        LOGGER.error(ex);
    }
    criteria.add(Restrictions.ge("activeFromTmb", timeTmb));
    return (PaySalaryComponent) criteria.uniqueResult();
}

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

@Override
public List<PaySalaryComponent> getAllDataByEmpTypeIdAndActiveFromTmAndIdNotIn(Long empTypeId, int fromTbm,
        List<Long> componentIds) {
    Criteria criteria = getCurrentSession().createCriteria(getEntityClass());
    criteria.createAlias("paySalaryEmpTypes", "payType");
    criteria.createAlias("payType.employeeType", "employeeType");
    criteria.add(Restrictions.eq("employeeType.id", empTypeId));
    criteria.add(Restrictions.le("activeFromTmb", fromTbm));
    if (!componentIds.isEmpty()) {
        criteria.add(Restrictions.not(Restrictions.in("id", componentIds)));
    }/*from   w  ww  .  j  a  va 2 s  .  c  om*/
    return criteria.list();
}