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
@Override public List<EmpData> getEmployeeBySearchEmployeeLeave(DistributionLeaveSchemeModel model) { DetachedCriteria listEmp = DetachedCriteria.forClass(LeaveDistribution.class) .setProjection(Property.forName("empData.id")).createAlias("leave", "lv", JoinType.INNER_JOIN) .add(Restrictions.eq("lv.id", model.getLeaveSchemeId())); Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); /**/*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.neOrIsNotNull("status", HRMConstant.EMP_TERMINATION)); // criteria.createAlias("leaveDistributions", "lv", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("employeeType", "empType", JoinType.INNER_JOIN); criteria.createAlias("bioData", "bio", JoinType.INNER_JOIN); criteria.createAlias("golonganJabatan", "goljab", JoinType.INNER_JOIN); criteria.add(Property.forName("id").notIn(listEmp)); criteria.add(Restrictions.eq("status", HRMConstant.EMP_TERMINATION)); //ambil yg working groupnya bukan yg dipilih, dan belum punya working group // if (model.getLeaveSchemeId() != 0 || model.getLeaveSchemeId() != null) { // Disjunction disjunction = Restrictions.disjunction(); // disjunction.add(Restrictions.isNull("lv.empData")); // disjunction.add(Restrictions.not(Restrictions.eq("lv.leave.id", model.getLeaveSchemeId()))); // criteria.add(disjunction); // } //balance // if (model.getStartBalance() != 0.0){ // criteria.add(Restrictions.eq("lv.balance", model.getStartBalance())); // } //departermen equal or like if (model.getDepartmentLikeOrEqual() != 3) { if (Objects.equals(model.getDepartmentLikeOrEqual(), HRMConstant.DEPARTMENT_EQUAL)) { criteria.add(Restrictions.eq("department.departmentName", model.getDepartmentName())); } else { criteria.add(Restrictions.like("department.departmentName", model.getDepartmentName(), MatchMode.ANYWHERE)); } } //employee type equal or likeS if (model.getEmployeeTypeLikeOrEqual() != 3) { if (Objects.equals(model.getEmployeeTypeLikeOrEqual(), HRMConstant.EMPLOYEE_TYPE_EQUAL)) { criteria.add(Restrictions.eq("empType.name", model.getEmployeeTypeName())); } else { criteria.add(Restrictions.like("empType.name", model.getEmployeeTypeName(), MatchMode.ANYWHERE)); } } //gender criteria.add(Restrictions.eq("bio.gender", model.getGender())); //goljab if (model.getGolonganJabatanId() != 0) { criteria.add(Restrictions.eq("goljab.id", model.getGolonganJabatanId())); } String sortBy; if (Objects.equals(model.getSortBy(), HRMConstant.SORT_BY_NIK)) { sortBy = "nik"; } else { sortBy = "bio.firstName"; } if (Objects.equals(model.getOrderBy(), HRMConstant.ORDER_BY_ASC)) { criteria.addOrder(Order.asc(sortBy)); } else { criteria.addOrder(Order.desc(sortBy)); } criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
@Override public List<EmpData> getEmployeeByOtSearchParameter(DistributionOvetTimeModel model) { DetachedCriteria listEmp = DetachedCriteria.forClass(OverTimeDistribution.class) .setProjection(Property.forName("empData.id")) .createAlias("wtOverTime", "wtOverTime", JoinType.INNER_JOIN) .add(Restrictions.eq("wtOverTime.id", model.getOverTimeId())); Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); /**//from w w w .j a v a2s. 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.neOrIsNotNull("status", HRMConstant.EMP_TERMINATION)); criteria.createAlias("overTimeDistributions", "ot", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("ot.wtOverTime", "wt", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("employeeType", "empType", JoinType.INNER_JOIN); criteria.createAlias("bioData", "bio", JoinType.INNER_JOIN); criteria.add(Property.forName("id").notIn(listEmp)); // criteria.createAlias("golonganJabatan", "goljab", JoinType.INNER_JOIN); /*if (model.getOverTimeId() != 0 || model.getOverTimeId() != null) { Criterion andCondition = Restrictions.conjunction() .add(Restrictions.isNotNull("ot.empData")) .add(Restrictions.not(Restrictions.eq("wt.id", model.getOverTimeId()))); // criteria.add(Restrictions.isNull("ot.empData")); Criterion completeCondition = Restrictions.disjunction().add(andCondition) .add(Restrictions.isNull("ot.empData")); // Disjunction conjunction = Restrictions.conjunction(); // disjunction.add(Restrictions.isNotNull("ot.empData")); // disjunction.add(Restrictions.not(Restrictions.eq("ot.wtOverTime.id", model.getOverTimeId()))); criteria.add(completeCondition); }*/ //balance // if (model.getStartBalance() != 0.0){ // criteria.add(Restrictions.eq("lv.balance", model.getStartBalance())); // } //departermen equal or like if (model.getDepartmentLikeOrEqual() != 3) { if (Objects.equals(model.getDepartmentLikeOrEqual(), HRMConstant.DEPARTMENT_EQUAL)) { criteria.add(Restrictions.eq("department.departmentName", model.getDepartmentName())); } else { criteria.add(Restrictions.like("department.departmentName", model.getDepartmentName(), MatchMode.ANYWHERE)); } } //employee type equal or likeS if (model.getEmployeeTypeLikeOrEqual() != 3) { if (Objects.equals(model.getEmployeeTypeLikeOrEqual(), HRMConstant.EMPLOYEE_TYPE_EQUAL)) { criteria.add(Restrictions.eq("empType.name", model.getEmployeeTypeName())); } else { criteria.add(Restrictions.like("empType.name", model.getEmployeeTypeName(), MatchMode.ANYWHERE)); } } //gender criteria.add(Restrictions.eq("bio.gender", model.getGender())); //goljab if (model.getGolonganJabatanId() != 0) { criteria.add(Restrictions.eq("goljab.id", model.getGolonganJabatanId())); } String sortBy; if (Objects.equals(model.getSortBy(), HRMConstant.SORT_BY_NIK)) { sortBy = "nik"; } else { sortBy = "bio.firstName"; } if (Objects.equals(model.getOrderBy(), HRMConstant.ORDER_BY_ASC)) { criteria.addOrder(Order.asc(sortBy)); } else { criteria.addOrder(Order.desc(sortBy)); } criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
@Override public List<EmpData> getAllDataReportEmpWorkingGroupByParam(ReportEmpWorkingGroupParameter param, int firstResult, int maxResults, Order orderable) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN); criteria.createAlias("wtGroupWorking", "wtGroupWorking", JoinType.LEFT_OUTER_JOIN); doSearchReportEmpWorkingGroupByParam(param, criteria); criteria.addOrder(orderable);/* www .j a va 2 s. c o m*/ criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
/** * automatically get relations of jabatanByJabatanId, department, company * don't create alias for that entity, or will get error : duplicate * association path//from w w w.j a va 2 s. c o m */ /* criteria = this.addJoinRelationsOfCompanyId(criteria, HrmUserInfoUtil.getCompanyId()); criteria.add(Restrictions.neOrIsNotNull("status", HRMConstant.EMP_TERMINATION)); // criteria.createAlias("leaveDistributions", "lv", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("employeeType", "empType", JoinType.INNER_JOIN); criteria.createAlias("bioData", "bio", JoinType.INNER_JOIN); criteria.createAlias("golonganJabatan", "goljab", JoinType.INNER_JOIN); criteria.add(Property.forName("id").notIn(listEmp)); //ambil yg working groupnya bukan yg dipilih, dan belum punya working group // if (model.getLeaveSchemeId() != 0 || model.getLeaveSchemeId() != null) { // Disjunction disjunction = Restrictions.disjunction(); // disjunction.add(Restrictions.isNull("lv.empData")); // disjunction.add(Restrictions.not(Restrictions.eq("lv.leave.id", model.getLeaveSchemeId()))); // criteria.add(disjunction); // } */ @Override public List<EmpData> getEmployeeBySearchEmployeePermit(PermitDistributionModel model) { DetachedCriteria listEmp = DetachedCriteria.forClass(PermitDistribution.class) .setProjection(Property.forName("empData.id")) .createAlias("permitClassification", "pc", JoinType.INNER_JOIN) .add(Restrictions.eq("pc.id", model.getPermitId())); 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.neOrIsNotNull("status", HRMConstant.EMP_TERMINATION)); criteria.createAlias("permitDistributions", "lv", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("employeeType", "empType", JoinType.INNER_JOIN); criteria.createAlias("bioData", "bio", JoinType.INNER_JOIN); criteria.createAlias("golonganJabatan", "goljab", JoinType.INNER_JOIN); criteria.add(Property.forName("id").notIn(listEmp)); //ambil yg working groupnya bukan yg dipilih, dan belum punya working group /*if (model.getPermitId() != 0 || model.getPermitId() != null) { Disjunction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.isNull("permitDistributions")); disjunction.add(Restrictions.not(Restrictions.eq("lv.permitClassification.id", model.getPermitId()))); //disjunction.add(Restrictions.sqlRestriction(sql, values, types)); criteria.add(disjunction); }*/ //balance // if (model.getStartBalance() != 0.0){ // criteria.add(Restrictions.eq("lv.balance", model.getStartBalance())); // } //departermen equal or like if (model.getDepartmentLikeOrEqual() != 3) { if (Objects.equals(model.getDepartmentLikeOrEqual(), HRMConstant.DEPARTMENT_EQUAL)) { criteria.add(Restrictions.eq("department.departmentName", model.getDepartmentName())); } else { criteria.add(Restrictions.like("department.departmentName", model.getDepartmentName(), MatchMode.ANYWHERE)); } } //employee type equal or likeS if (model.getEmployeeTypeLikeOrEqual() != 3) { if (Objects.equals(model.getEmployeeTypeLikeOrEqual(), HRMConstant.EMPLOYEE_TYPE_EQUAL)) { criteria.add(Restrictions.eq("empType.name", model.getEmployeeTypeName())); } else { criteria.add(Restrictions.like("empType.name", model.getEmployeeTypeName(), MatchMode.ANYWHERE)); } } //gender criteria.add(Restrictions.eq("bio.gender", model.getGender())); //goljab if (model.getGolonganJabatanId() != 0) { criteria.add(Restrictions.eq("goljab.id", model.getGolonganJabatanId())); } String sortBy; if (Objects.equals(model.getSortBy(), HRMConstant.SORT_BY_NIK)) { sortBy = "nik"; } else { sortBy = "bio.firstName"; } if (Objects.equals(model.getOrderBy(), HRMConstant.ORDER_BY_ASC)) { criteria.addOrder(Order.asc(sortBy)); } else { criteria.addOrder(Order.desc(sortBy)); } criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
@Override public List<EmpData> getAllDataReportEmpDepartmentJabatanByParam(ReportEmpDepartmentJabatanParameter param, int firstResult, int maxResults, Order orderable) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN); criteria.createAlias("golonganJabatan", "goljab", JoinType.INNER_JOIN); doSearchReportEmpDepartmentJabatanByParam(param, criteria); criteria.addOrder(orderable);/*from w w w .j a v a2 s . com*/ criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
@Override public Long getTotalReportEmpDepartmentJabatanByParam(ReportEmpDepartmentJabatanParameter param) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.createAlias("golonganJabatan", "goljab", JoinType.INNER_JOIN); doSearchReportEmpDepartmentJabatanByParam(param, criteria); return (Long) criteria.setProjection(Projections.rowCount()).uniqueResult(); }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
public List<EmpData> getEmployeeBySearchEmployeeFingerException(WtFingerExceptionModel model) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); /**/*ww w .j a va2 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.add(Restrictions.neOrIsNotNull("status", HRMConstant.EMP_TERMINATION)); criteria.createAlias("employeeType", "empType", JoinType.INNER_JOIN); criteria.createAlias("bioData", "bio", JoinType.INNER_JOIN); criteria.createAlias("golonganJabatan", "goljab", JoinType.INNER_JOIN); //ambil yg working groupnya bukan yg dipilih, dan belum punya working group // if (model.getLeaveSchemeId() != 0 || model.getLeaveSchemeId() != null) { // Disjunction disjunction = Restrictions.disjunction(); // disjunction.add(Restrictions.isNull("lv.empData")); // disjunction.add(Restrictions.not(Restrictions.eq("lv.leave.id", model.getLeaveSchemeId()))); // criteria.add(disjunction); // } //departermen equal or like if (model.getDepartmentLikeOrEqual() != 3) { if (Objects.equals(model.getDepartmentLikeOrEqual(), HRMConstant.DEPARTMENT_EQUAL)) { criteria.add(Restrictions.eq("department.departmentName", model.getDepartmentName())); } else { criteria.add(Restrictions.like("department.departmentName", model.getDepartmentName(), MatchMode.ANYWHERE)); } } //employee type equal or likeS if (model.getEmployeeTypeLikeOrEqual() != 3) { if (Objects.equals(model.getEmployeeTypeLikeOrEqual(), HRMConstant.EMPLOYEE_TYPE_EQUAL)) { criteria.add(Restrictions.eq("empType.name", model.getEmployeeTypeName())); } else { criteria.add(Restrictions.like("empType.name", model.getEmployeeTypeName(), MatchMode.ANYWHERE)); } } //gender criteria.add(Restrictions.eq("bio.gender", model.getGender())); //goljab if (model.getGolonganJabatanId() != 0) { criteria.add(Restrictions.eq("goljab.id", model.getGolonganJabatanId())); } String sortBy; if (Objects.equals(model.getSortBy(), HRMConstant.SORT_BY_NIK)) { sortBy = "nik"; } else { sortBy = "bio.firstName"; } if (Objects.equals(model.getOrderBy(), HRMConstant.ORDER_BY_ASC)) { criteria.addOrder(Order.asc(sortBy)); } else { criteria.addOrder(Order.desc(sortBy)); } return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
@Override public EmpData getEmpDataWithBiodata(Long id) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.add(Restrictions.eq("id", id)); criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN); criteria.createAlias("bioData.maritalStatus", "maritalStatus", JoinType.INNER_JOIN); criteria.setFetchMode("bioData", FetchMode.JOIN); criteria.setFetchMode("maritalStatus", FetchMode.JOIN); return (EmpData) criteria.uniqueResult(); }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
@Override public List<EmpData> getAllDataNotTerminateWithSearchParameter(String nikOrName) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); /**/*from w ww . 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("bioData", "bioData", JoinType.INNER_JOIN); if (nikOrName != null) { Disjunction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.ilike("bioData.combineName", nikOrName.toLowerCase(), MatchMode.ANYWHERE)); disjunction.add(Restrictions.like("nik", nikOrName, MatchMode.ANYWHERE)); criteria.add(disjunction); } return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.EmpDataDaoImpl.java
@Override public List<EmpData> getAllDataWithoutJoinCompany(String nikOrName) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.add(Restrictions.not(Restrictions.eq("status", HRMConstant.EMP_TERMINATION))); if (StringUtils.isNotEmpty(nikOrName)) { criteria.createAlias("bioData", "bioData", JoinType.INNER_JOIN); Disjunction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.ilike("bioData.combineName", nikOrName.toLowerCase(), MatchMode.ANYWHERE)); disjunction.add(Restrictions.like("nik", nikOrName, MatchMode.ANYWHERE)); criteria.add(disjunction);//from w w w . j a v a 2 s .c o m } return criteria.list(); }