List of usage examples for org.hibernate Criteria createAlias
@Deprecated public Criteria createAlias(String associationPath, String alias, int joinType) throws HibernateException;
From source file:com.inkubator.hrm.dao.impl.EmpRotasiDaoImpl.java
private void doSearchEmpRotasiByParam(EmpRotasiSearchParameter searchParameter, Criteria criteria) { if (searchParameter.getNIK() != null) { criteria.createAlias("empData", "ep", JoinType.INNER_JOIN); criteria.add(Restrictions.like("ep.nik", searchParameter.getNIK(), MatchMode.START)); }//w w w . j a v a 2s. c o m if (searchParameter.getName() != null) { criteria.createAlias("empData", "ep", JoinType.INNER_JOIN); criteria.createAlias("ep.bioData", "bio", JoinType.INNER_JOIN); criteria.add(Restrictions.like("bio.firstName", searchParameter.getName(), MatchMode.START)); } if (searchParameter.getJabatanLama() != null) { criteria.createAlias("jabatanByOldFunctionId", "jbo", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("jbo.name", searchParameter.getJabatanLama())); } if (searchParameter.getJabatanBaru() != null) { criteria.createAlias("jabatanByNewFunctionId", "jbn", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("jbn.name", searchParameter.getJabatanBaru())); } criteria.add(Restrictions.isNotNull("id")); }
From source file:com.inkubator.hrm.dao.impl.GolonganJabatanDaoImpl.java
private void doSearchByParam(GolonganJabatanSearchParameter parameter, Criteria criteria) { criteria.createAlias("pangkat", "pangkat", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("paySalaryGrade", "paySalaryGrade", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("paySalaryGrade.currency", "currency", JoinType.LEFT_OUTER_JOIN); if (StringUtils.isNotEmpty(parameter.getCode())) { criteria.add(Restrictions.like("code", parameter.getCode(), MatchMode.ANYWHERE)); }//from w w w . jav a 2 s . c o m if (StringUtils.isNotEmpty(parameter.getPangkatName())) { criteria.add(Restrictions.like("pangkat.pangkatName", parameter.getPangkatName(), MatchMode.ANYWHERE)); } criteria.add(Restrictions.isNotNull("id")); }
From source file:com.inkubator.hrm.dao.impl.HrmMenuRoleDoaImpl.java
@Override public List<HrmMenuRole> getByLevelOneAndRoleName(String name) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.createAlias("hrmRole", "hr", JoinType.INNER_JOIN); criteria.createAlias("hrmMenu", "hm", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("hr.roleName", name)); criteria.add(Restrictions.eq("hm.menuLevel", 1)); criteria.addOrder(Order.asc("hm.orderLevelMenu")); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.HrmUserDaoImpl.java
@Override public List<HrmUser> getAllDataByNameOrNik(String param) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.createAlias("empData", "empData", JoinType.INNER_JOIN); criteria.createAlias("empData.bioData", "bioData", JoinType.INNER_JOIN); Disjunction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.like("bioData.firstName", param, MatchMode.ANYWHERE)); disjunction.add(Restrictions.like("bioData.lastName", param, MatchMode.ANYWHERE)); disjunction.add(Restrictions.like("empData.nik", param, MatchMode.ANYWHERE)); criteria.add(disjunction);/* www .j a v a 2 s. c om*/ return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.InclusionReimbursmentDaoImpl.java
private void doSearchByParam(String parameter, Criteria criteria, InclusionReimbursmentModel inclusionReimbursmentModel) { criteria.createAlias("reimbursmentSchema", "reimbursmentSchema", JoinType.INNER_JOIN); criteria.createAlias("empData", "empData", JoinType.INNER_JOIN); criteria.createAlias("empData.bioData", "bioData", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("reimbursmentSchema.payrollComponent", Boolean.TRUE)); criteria.add(Restrictions.ge("claimDate", inclusionReimbursmentModel.getStartDate())); criteria.add(Restrictions.lt("claimDate", inclusionReimbursmentModel.getEndDate())); if (StringUtils.isNotEmpty(parameter)) { Disjunction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.like("empData.nik", parameter, MatchMode.ANYWHERE)); disjunction.add(Restrictions.like("bioData.firstName", parameter, MatchMode.ANYWHERE)); disjunction.add(Restrictions.like("bioData.lastName", parameter, MatchMode.ANYWHERE)); criteria.add(disjunction);/*w w w . j a v a 2 s .com*/ // criteria.add(Restrictions.like("bioData.firstName", parameter, MatchMode.ANYWHERE)); } criteria.add(Restrictions.isNotNull("id")); }
From source file:com.inkubator.hrm.dao.impl.InclusionReimbursmentDaoImpl.java
@Override public List<Reimbursment> getByWtPeriodeWhereComponentPayrollIsActive( InclusionReimbursmentModel inclusionReimbursmentModel) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.createAlias("reimbursmentSchema", "reimbursmentSchema", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("reimbursmentSchema.payrollComponent", Boolean.TRUE)); criteria.add(Restrictions.ge("claimDate", inclusionReimbursmentModel.getStartDate())); criteria.add(Restrictions.lt("claimDate", inclusionReimbursmentModel.getEndDate())); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.JabatanDaoImpl.java
private Criteria addJoinRelationsOfCompanyId(Criteria criteria, Long companyId) { criteria.createAlias("department", "department", JoinType.INNER_JOIN); criteria.createAlias("department.company", "company", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("company.id", companyId)); return criteria; }
From source file:com.inkubator.hrm.dao.impl.JabatanDaoImpl.java
@Override public List<Jabatan> getByParam(JabatanSearchParameter searchParameter, int firstResult, int maxResults, Order order) {//from w ww . j a v a 2 s . co m Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); // criteria.setFetchMode("costCenter", FetchMode.JOIN); // criteria.setFetchMode("golonganJabatan", FetchMode.JOIN); // criteria.setFetchMode("department", FetchMode.JOIN); // criteria.setFetchMode("unitKerja", FetchMode.JOIN); // criteria.setFetchMode("jabatan", FetchMode.JOIN); // criteria.setFetchMode("paySalaryGrade", FetchMode.JOIN); criteria.createAlias("costCenter", "costCenter", JoinType.INNER_JOIN); criteria.createAlias("golonganJabatan", "golonganJabatan", JoinType.INNER_JOIN); criteria.createAlias("golonganJabatan.pangkat", "pangkat", JoinType.INNER_JOIN); criteria.createAlias("department", "department", JoinType.INNER_JOIN); criteria.createAlias("unitKerja", "unitKerja", JoinType.INNER_JOIN); criteria.createAlias("jabatan", "jabatan", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("paySalaryGrade", "paySalaryGrade", JoinType.INNER_JOIN); doSearchByParam(searchParameter, criteria); criteria.addOrder(order); criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.JabatanDaoImpl.java
@Override public Long getTotalJabatanByParam(JabatanSearchParameter searchParameter) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.setFetchMode("costCenter", FetchMode.JOIN); criteria.setFetchMode("golonganJabatan", FetchMode.JOIN); criteria.setFetchMode("department", FetchMode.JOIN); criteria.setFetchMode("unitKerja", FetchMode.JOIN); criteria.setFetchMode("jabatan", FetchMode.JOIN); criteria.setFetchMode("paySalaryGrade", FetchMode.JOIN); criteria.createAlias("costCenter", "costCenter", JoinType.INNER_JOIN); criteria.createAlias("golonganJabatan", "golonganJabatan", JoinType.INNER_JOIN); criteria.createAlias("golonganJabatan.pangkat", "pangkat", JoinType.INNER_JOIN); criteria.createAlias("department", "department", JoinType.INNER_JOIN); criteria.createAlias("unitKerja", "unitKerja", JoinType.INNER_JOIN); criteria.createAlias("jabatan", "jabatan", JoinType.INNER_JOIN); criteria.createAlias("paySalaryGrade", "paySalaryGrade", JoinType.INNER_JOIN); doSearchByParam(searchParameter, criteria); return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult(); }
From source file:com.inkubator.hrm.dao.impl.JabatanDaoImpl.java
private void doSearchByParam(JabatanSearchParameter parameter, Criteria criteria) { /** automatically get relations of department, company * don't create alias for that entity, or will get error : duplicate association path */ // criteria = this.addJoinRelationsOfCompanyId(criteria, HrmUserInfoUtil.getCompanyId()); criteria.createAlias("department.company", "company", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("company.id", HrmUserInfoUtil.getCompanyId())); if (StringUtils.isNotEmpty(parameter.getCode())) { criteria.add(Restrictions.like("code", parameter.getCode(), MatchMode.ANYWHERE)); }//from w w w . j ava 2s . c o m if (StringUtils.isNotEmpty(parameter.getGolJab())) { criteria.add(Restrictions.like("golonganJabatan.code", parameter.getGolJab(), MatchMode.ANYWHERE)); } if (StringUtils.isNotEmpty(parameter.getName())) { criteria.add(Restrictions.like("name", parameter.getName(), MatchMode.ANYWHERE)); } if (StringUtils.isNotEmpty(parameter.getCostCenterName())) { criteria.add(Restrictions.like("costCenter.name", parameter.getCostCenterName(), MatchMode.ANYWHERE)); } if (StringUtils.isNotEmpty(parameter.getDepartementName())) { criteria.add(Restrictions.like("department.departmentName", parameter.getDepartementName(), MatchMode.ANYWHERE)); } if (StringUtils.isNotEmpty(parameter.getJabatan())) { criteria.add(Restrictions.like("pangkat.pangkatName", parameter.getJabatan(), MatchMode.ANYWHERE)); } if (StringUtils.isNotEmpty(parameter.getUnitKerjaName())) { criteria.add(Restrictions.like("unitKerja.name", parameter.getUnitKerjaName(), MatchMode.ANYWHERE)); } criteria.add(Restrictions.isNotNull("id")); }