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.EmpDataDaoImpl.java
private Criteria doSearchSalaryConfirmationByParam(SalaryConfirmationParameter param, Criteria criteria) { /**/* w w w.j a v a 2 s . com*/ * automatically get relations of jabatanByJabatanId, department, * company don't create alias for that entity, or will get error : * duplicate association path */ criteria = this.addJoinRelationsOfCompanyId(criteria, HrmUserInfoUtil.getCompanyId()); criteria.add(Restrictions.not(Restrictions.eq("status", HRMConstant.EMP_TERMINATION))); criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN); criteria.createAlias("golonganJabatan", "golonganJabatan", JoinType.INNER_JOIN); criteria.add(Restrictions.isNotEmpty("payTempKalkulasis")); if (StringUtils.isNotEmpty(param.getNik())) { criteria.add(Restrictions.like("nik", param.getNik(), MatchMode.START)); } if (StringUtils.isNotEmpty(param.getName())) { Disjunction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.like("bioData.firstName", param.getName(), MatchMode.START)); disjunction.add(Restrictions.like("bioData.lastName", param.getName(), MatchMode.START)); criteria.add(disjunction); } if (param.getGolonganJabatanId() != null && param.getGolonganJabatanId() != 0) { criteria.add(Restrictions.eq("golonganJabatan.id", param.getGolonganJabatanId())); } return criteria; }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
@Override public EmpData getByEmpDataByBioDataId(long bioDataid) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN); criteria.setFetchMode("bioData", FetchMode.JOIN); criteria.setFetchMode("jabatanByJabatanId", FetchMode.JOIN); criteria.setFetchMode("jabatanByJabatanId.department", FetchMode.JOIN); criteria.setFetchMode("jabatanByJabatanId.department.company", FetchMode.JOIN); criteria.setFetchMode("employeeType", FetchMode.JOIN); criteria.setFetchMode("golonganJabatan", FetchMode.JOIN); criteria.setFetchMode("golonganJabatan.pangkat", FetchMode.JOIN); criteria.add(Restrictions.eq("bioData.id", bioDataid)); return (EmpData) criteria.uniqueResult(); }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
public void doCreateAliasByDepartmentAndEducation(List<Long> departementId, List<Long> educationId, Criteria criteria) { /**//from w w w.j av a 2 s.c om * automatically get relations of jabatanByJabatanId, department, * company don't create alias for that entity, or will get error : * duplicate association path */ criteria = this.addJoinRelationsOfCompanyId(criteria, HrmUserInfoUtil.getCompanyId()); criteria.add(Restrictions.not(Restrictions.eq("status", HRMConstant.EMP_TERMINATION))); criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN); criteria.createAlias("bioData.educationHistories", "educationHistories", JoinType.INNER_JOIN); criteria.createAlias("educationHistories.educationLevel", "educationLevel", JoinType.INNER_JOIN); if (departementId.isEmpty() != Boolean.TRUE) { criteria.add(Restrictions.in("department.id", departementId)); } if (educationId.isEmpty() != Boolean.TRUE) { criteria.add(Restrictions.in("educationLevel.id", educationId)); } }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
public void doCreateAliasByDepartmentAndEmployeeType(List<Long> listDepartmentId, List<Long> listEmployeeTypeId, Criteria criteria) { /**//from www . j a v a 2 s . c o m * automatically get relations of jabatanByJabatanId, department, * company don't create alias for that entity, or will get error : * duplicate association path */ criteria = this.addJoinRelationsOfCompanyId(criteria, HrmUserInfoUtil.getCompanyId()); criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN); criteria.createAlias("golonganJabatan", "golonganJabatan", JoinType.INNER_JOIN); criteria.createAlias("employeeType", "employeeType", JoinType.INNER_JOIN); if (!listDepartmentId.isEmpty()) { criteria.add(Restrictions.in("department.id", listDepartmentId)); } if (!listEmployeeTypeId.isEmpty()) { criteria.add(Restrictions.in("employeeType.id", listEmployeeTypeId)); } }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
@Override public List<EmpData> getAllDataByDepartmentAndReligionAndGolJabAndEmpType(List<Long> departmentIds, List<Long> religionIds, List<Long> golJabIds, List<Long> empTypeIds) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.add(Restrictions.not(Restrictions.eq("status", HRMConstant.EMP_TERMINATION))); criteria.createAlias("jabatanByJabatanId", "jabatanByJabatanId", JoinType.INNER_JOIN); criteria.createAlias("jabatanByJabatanId.department", "department", JoinType.INNER_JOIN); criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN); criteria.createAlias("bioData.religion", "religion", JoinType.INNER_JOIN); if (!departmentIds.isEmpty()) { criteria.add(Restrictions.in("department.id", departmentIds)); }/*from w w w . j av a 2s . c om*/ if (!religionIds.isEmpty()) { criteria.add(Restrictions.in("religion.id", religionIds)); } if (!golJabIds.isEmpty()) { criteria.add(Restrictions.in("golonganJabatan.id", golJabIds)); } if (!empTypeIds.isEmpty()) { criteria.add(Restrictions.in("employeeType.id", empTypeIds)); } return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
@Override public List<EmpData> getAllDataByParamWithDetail(List<Department> deptId, List<GolonganJabatan> golJabId, String[] empTypeName, List<Integer> listAge, List<Integer> listJoinDate, List<String> listNik, int firstResult, int maxResults, Order order) { List<Long> listDepartment = new ArrayList<Long>(); List<Long> listGolJab = new ArrayList<Long>(); for (Department department : deptId) { listDepartment.add(department.getId()); }/*from w ww .ja v a 2s . c o m*/ for (GolonganJabatan golonganJabatan : golJabId) { listGolJab.add(golonganJabatan.getId()); } final org.hibernate.type.Type[] typeJoinDate = new org.hibernate.type.Type[listJoinDate.size()]; Arrays.fill(typeJoinDate, org.hibernate.type.StandardBasicTypes.INTEGER); final org.hibernate.type.Type[] typeAge = new org.hibernate.type.Type[listAge.size()]; Arrays.fill(typeAge, org.hibernate.type.StandardBasicTypes.INTEGER); final StringBuilder joinDateList = new StringBuilder(); final StringBuilder ageList = new StringBuilder(); for (int i = 0; i < listJoinDate.size(); i++) { if (i > 0) { joinDateList.append(","); } joinDateList.append("?"); } for (int i = 0; i < listAge.size(); i++) { if (i > 0) { ageList.append(","); } ageList.append("?"); } Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); /** * automatically get relations of jabatanByJabatanId, department, * company don't create alias for that entity, or will get error : * duplicate association path */ criteria = this.addJoinRelationsOfCompanyId(criteria, HrmUserInfoUtil.getCompanyId()); criteria.add(Restrictions.not(Restrictions.eq("status", HRMConstant.EMP_TERMINATION))); // criteria.createAlias("bioData", "bioData", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("golonganJabatan", "golonganJabatan", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("employeeType", "employeeType", JoinType.LEFT_OUTER_JOIN); // criteria.createCriteria("bioData", "bio", JoinType.LEFT_OUTER_JOIN); if (!deptId.isEmpty()) { criteria.add(Restrictions.in("department.id", listDepartment)); } if (!golJabId.isEmpty()) { criteria.add(Restrictions.in("golonganJabatan.id", listGolJab)); } if (empTypeName.length != 0) { criteria.add(Restrictions.in("employeeType.name", empTypeName)); } if (listJoinDate.get(0) != 0) { criteria.add(Restrictions .sqlRestriction("DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS({alias}.join_date)), '%Y')+0 in (" + joinDateList.toString() + ")", listJoinDate.toArray(), typeJoinDate)); } if (listAge.get(0) != 0) { // criteria.createAlias("bioData", "bioData", JoinType.LEFT_OUTER_JOIN); Criteria criteriaBiodata = criteria.createCriteria("bioData", JoinType.LEFT_OUTER_JOIN); // criteria.createCriteria("bioData", JoinType.LEFT_OUTER_JOIN); criteriaBiodata.add(Restrictions.sqlRestriction( "DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS({alias}.date_of_birth)), '%Y')+0 in (" + ageList.toString() + ")", listAge.toArray(), typeAge)); } if (!listNik.isEmpty()) { criteria.add(Restrictions.in("nik", listNik)); } criteria.addOrder(order); criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
@Override public Long getTotalByParamWithDetail(List<Department> deptId, List<GolonganJabatan> golJabId, String[] empTypeName, List<Integer> listAge, List<Integer> listJoinDate, List<String> listNik) { List<Long> listDepartment = new ArrayList<Long>(); List<Long> listGolJab = new ArrayList<Long>(); for (Department department : deptId) { listDepartment.add(department.getId()); }/*from w ww.j a v a2 s. c o m*/ for (GolonganJabatan golonganJabatan : golJabId) { listGolJab.add(golonganJabatan.getId()); } final org.hibernate.type.Type[] typeJoinDate = new org.hibernate.type.Type[listJoinDate.size()]; Arrays.fill(typeJoinDate, org.hibernate.type.StandardBasicTypes.INTEGER); final org.hibernate.type.Type[] typeAge = new org.hibernate.type.Type[listAge.size()]; Arrays.fill(typeAge, org.hibernate.type.StandardBasicTypes.INTEGER); final StringBuilder joinDateList = new StringBuilder(); final StringBuilder ageList = new StringBuilder(); for (int i = 0; i < listJoinDate.size(); i++) { if (i > 0) { joinDateList.append(","); } joinDateList.append("?"); } for (int i = 0; i < listAge.size(); i++) { if (i > 0) { ageList.append(","); } ageList.append("?"); } Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); /** * automatically get relations of jabatanByJabatanId, department, * company don't create alias for that entity, or will get error : * duplicate association path */ criteria = this.addJoinRelationsOfCompanyId(criteria, HrmUserInfoUtil.getCompanyId()); criteria.add(Restrictions.not(Restrictions.eq("status", HRMConstant.EMP_TERMINATION))); // criteria.createAlias("bioData", "bioData", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("golonganJabatan", "golonganJabatan", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("employeeType", "employeeType", JoinType.LEFT_OUTER_JOIN); // criteria.createCriteria("bioData", "bio", JoinType.LEFT_OUTER_JOIN); if (!deptId.isEmpty()) { criteria.add(Restrictions.in("department.id", listDepartment)); } if (!golJabId.isEmpty()) { criteria.add(Restrictions.in("golonganJabatan.id", listGolJab)); } if (empTypeName.length != 0) { criteria.add(Restrictions.in("employeeType.name", empTypeName)); } if (listJoinDate.get(0) != 0) { criteria.add(Restrictions .sqlRestriction("DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS({alias}.join_date)), '%Y')+0 in (" + joinDateList.toString() + ")", listJoinDate.toArray(), typeJoinDate)); } if (listAge.get(0) != 0) { Criteria criteriaBiodata = criteria.createCriteria("bioData", JoinType.LEFT_OUTER_JOIN); // criteria.createCriteria("bioData", JoinType.LEFT_OUTER_JOIN); criteriaBiodata.add(Restrictions.sqlRestriction( "DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS({alias}.date_of_birth)), '%Y')+0 in (" + ageList.toString() + ")", listAge.toArray(), typeAge)); } if (!listNik.isEmpty()) { criteria.add(Restrictions.in("nik", listNik)); } return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult(); }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
@Override public List<EmpData> getAllDataByEmployeeTypeOrGolonganJabatanOrUnitKerja(List<Long> empTypeId, List<Long> golJabId, List<Long> unitKerjaId, int firstResult, int maxResults, Order order) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); /**/*from ww w . j a v a 2s .c o m*/ * automatically get relations of jabatanByJabatanId, department, * company don't create alias for that entity, or will get error : * duplicate association path */ criteria = this.addJoinRelationsOfCompanyId(criteria, HrmUserInfoUtil.getCompanyId()); criteria.add(Restrictions.not(Restrictions.eq("status", HRMConstant.EMP_TERMINATION))); criteria.createAlias("jabatanByJabatanId.unitKerja", "unitKerja", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("jabatanByJabatanId.golonganJabatan", "goljab", JoinType.LEFT_OUTER_JOIN); // criteria.createAlias("department.company", "company", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("employeeType", "employeeType", JoinType.LEFT_OUTER_JOIN); criteria.setFetchMode("bioData", FetchMode.JOIN); if (!empTypeId.isEmpty()) { criteria.add(Restrictions.in("employeeType.id", empTypeId)); } if (!golJabId.isEmpty()) { criteria.add(Restrictions.in("goljab.id", golJabId)); } if (!unitKerjaId.isEmpty()) { criteria.add(Restrictions.in("unitKerja.id", unitKerjaId)); } criteria.addOrder(order); criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
@Override public Long getTotalDataByEmployeeTypeOrGolonganJabatanOrUnitKerja(List<Long> empTypeId, List<Long> golJabId, List<Long> unitKerjaId) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); /**//from w w w . jav a 2 s. co m * automatically get relations of jabatanByJabatanId, department, * company don't create alias for that entity, or will get error : * duplicate association path */ criteria = this.addJoinRelationsOfCompanyId(criteria, HrmUserInfoUtil.getCompanyId()); criteria.add(Restrictions.not(Restrictions.eq("status", HRMConstant.EMP_TERMINATION))); criteria.createAlias("jabatanByJabatanId.unitKerja", "unitKerja", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("jabatanByJabatanId.golonganJabatan", "goljab", JoinType.LEFT_OUTER_JOIN); // criteria.createAlias("department.company", "company", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("employeeType", "employeeType", JoinType.LEFT_OUTER_JOIN); if (!empTypeId.isEmpty()) { criteria.add(Restrictions.in("employeeType.id", empTypeId)); } if (!golJabId.isEmpty()) { criteria.add(Restrictions.in("goljab.id", golJabId)); } if (!unitKerjaId.isEmpty()) { criteria.add(Restrictions.in("unitKerja.id", unitKerjaId)); } return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult(); }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
@Override public String getBioDataNameByEmpDataId(Long id) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.add(Restrictions.eq("id", id)); criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN); return (String) criteria.setProjection(Projections.property("bioData.firstName")).uniqueResult(); }