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.JabatanDaoImpl.java
@Override public List<Jabatan> getJabatanByParentCode(String parentCode) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); /** 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("jabatan", "jb", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("jb.code", parentCode)); criteria.setFetchMode("jabatans", FetchMode.JOIN); criteria.setFetchMode("jabatans.jabatan", FetchMode.JOIN); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.KlasifikasiKerjaLevelDaoImpl.java
@Override public List<KlasifikasiKerjaLevel> getByParam(KlasifikasiKerjaLevelSearchParameter searchParameter, int firstResult, int maxResults, Order order) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); doSearchByParam(searchParameter, criteria); criteria.addOrder(order);//from ww w . j a va 2s . c o m criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); criteria.createAlias("klasifikasiKerja", "klasifikasiKerja", JoinType.INNER_JOIN); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.LoanCanceledDaoImpl.java
@Override public List<LoanCanceled> getByParam(LoanCanceledSearchParameter searchParameter, int firstResult, int maxResults, Order order) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); doSearchByParam(searchParameter, criteria); criteria.createAlias("loan", "loan", JoinType.INNER_JOIN); criteria.createAlias("loan.loanSchema", "loanSchema", JoinType.INNER_JOIN); criteria.setFetchMode("loan.empData", FetchMode.JOIN); criteria.setFetchMode("loan.empData.bioData", FetchMode.JOIN); criteria.add(Restrictions.eq("loan.statusPencairan", HRMConstant.LOAN_CANCELED)); criteria.addOrder(order);//from w w w . j a va2s . c o m criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.LoanCanceledDaoImpl.java
private void doSearchByParam(LoanCanceledSearchParameter searchParameter, Criteria criteria) { if (StringUtils.isNotEmpty(searchParameter.getLoanSchema())) { criteria.createAlias("loanSchema", "loanSchema", JoinType.INNER_JOIN); criteria.add(Restrictions.like("loanSchema.name", searchParameter.getLoanSchema(), MatchMode.ANYWHERE)); }//from w w w. j a v a 2 s . c o m if (StringUtils.isNotEmpty(searchParameter.getEmployee())) { criteria.createAlias("empData", "empData", JoinType.INNER_JOIN); criteria.createAlias("empData.bioData", "bioData", JoinType.INNER_JOIN); Disjunction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.like("empData.nik", searchParameter.getEmployee(), MatchMode.ANYWHERE)); disjunction .add(Restrictions.like("bioData.firstName", searchParameter.getEmployee(), MatchMode.ANYWHERE)); disjunction .add(Restrictions.like("bioData.lastName", searchParameter.getEmployee(), MatchMode.ANYWHERE)); criteria.add(disjunction); } criteria.add(Restrictions.isNotNull("id")); }
From source file:com.inkubator.hrm.dao.impl.LoanCanceledDaoImpl.java
@Override public LoanCanceled getEntityByPkWithDetail(Long id) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.add(Restrictions.eq("id", id)); criteria.createAlias("loan", "loan", JoinType.INNER_JOIN); criteria.createAlias("loan.loanSchema", "loanSchema", JoinType.INNER_JOIN); criteria.setFetchMode("loan.empData", FetchMode.JOIN); criteria.setFetchMode("loan.empData.bioData", FetchMode.JOIN); return (LoanCanceled) criteria.uniqueResult(); }
From source file:com.inkubator.hrm.dao.impl.LoanNewApplicationDaoImpl.java
private void doSearchByParam(LoanNewSearchParameter parameter, Criteria criteria) { if (StringUtils.isNotEmpty(parameter.getLoanType())) { criteria.createAlias("loanNewType", "loanNewType", JoinType.INNER_JOIN); criteria.add(// w w w .ja v a 2s . c o m Restrictions.like("loanNewType.loanTypeName", parameter.getLoanType(), MatchMode.ANYWHERE)); } if (StringUtils.isNotEmpty(parameter.getEmployee())) { criteria.createAlias("empData", "empData", JoinType.INNER_JOIN); criteria.createAlias("empData.bioData", "bioData", JoinType.INNER_JOIN); Disjunction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.like("empData.nik", parameter.getEmployee(), MatchMode.ANYWHERE)); disjunction.add(Restrictions.like("bioData.firstName", parameter.getEmployee(), MatchMode.ANYWHERE)); disjunction.add(Restrictions.like("bioData.lastName", parameter.getEmployee(), MatchMode.ANYWHERE)); criteria.add(disjunction); } criteria.add(Restrictions.isNotNull("id")); }
From source file:com.inkubator.hrm.dao.impl.LoanNewApplicationInstallmentDaoImpl.java
@Override public List<LoanNewApplicationInstallment> getAllDataDisbursedByEmpDataIdAndLoanTypeIdAndPeriodDate( Long empDataId, Long loanTypeId, Date startPeriodDate, Date endPeriodDate) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.createAlias("loanNewApplication", "loanNewApplication", JoinType.INNER_JOIN); criteria.createAlias("loanNewApplication.empData", "empData", JoinType.INNER_JOIN); criteria.createAlias("loanNewApplication.loanNewType", "loanNewType", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("loanNewType.id", loanTypeId)); criteria.add(Restrictions.eq("empData.id", empDataId)); criteria.add(Restrictions.le("installmentDate", endPeriodDate)); criteria.add(Restrictions.ge("installmentDate", startPeriodDate)); criteria.add(Restrictions.ge("loanNewApplication.loanStatus", HRMConstant.LOAN_DISBURSED)); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.LoanNewApplicationInstallmentDaoImpl.java
@Override public List<LoanNewApplicationInstallment> getListByLoanNewApplicationId(Integer loanNewApplicationId) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.createAlias("loanNewApplication", "loanNewApplication", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("loanNewApplication.id", loanNewApplicationId)); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.LoanNewApplicationInstallmentDaoImpl.java
@Override public LoanNewApplicationInstallment getLastPaidTerminInstallment(Integer LoanNewApplicationid) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.createAlias("loanNewApplication", "loanNewApplication", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("loanNewApplication.id", LoanNewApplicationid)); DetachedCriteria criteriaWtPeriod = DetachedCriteria.forClass(WtPeriode.class) .add(Restrictions.eq("payrollType", HRMConstant.PERIODE_PAYROLL_ACTIVE)) .setProjection(Property.forName("fromPeriode")); criteria.add(Subqueries.propertyLt("installmentDate", criteriaWtPeriod)); criteria.addOrder(Order.desc("numOfInstallment")); criteria.setMaxResults(1);/* w w w .j av a2 s. co m*/ LoanNewApplicationInstallment currentNextInstallment = (LoanNewApplicationInstallment) criteria .uniqueResult(); return currentNextInstallment; }
From source file:com.inkubator.hrm.dao.impl.LoanNewSchemaListOfTypeDaoImpl.java
@Override public List<LoanNewSchemaListOfType> getEntityByLoanNewSchema(Long loanNewSchema) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.createAlias("loanNewSchema", "loanNewSchema", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("loanNewSchema.id", loanNewSchema)); criteria.setFetchMode("loanNewType", FetchMode.JOIN); return criteria.list(); }