List of usage examples for org.hibernate.criterion DetachedCriteria createAlias
public DetachedCriteria createAlias(String associationPath, String alias)
From source file:com.ut.tekir.finance.ChequeFromContactPayrollBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(ChequeFromContactPayroll.class); crit.createAlias("this.contact", "contact"); crit.createAlias("this.account", "account"); crit.setProjection(Projections.projectionList().add(Projections.property("this.id"), "id") .add(Projections.property("this.serial"), "serial") .add(Projections.property("this.reference"), "reference") .add(Projections.property("this.code"), "code").add(Projections.property("this.date"), "date") .add(Projections.property("this.info"), "info") .add(Projections.property("contact.code"), "contactCode") .add(Projections.property("contact.person"), "person") .add(Projections.property("contact.company"), "company") .add(Projections.property("contact.fullname"), "contactName") .add(Projections.property("account.code"), "accountCode") .add(Projections.property("account.name"), "accountName")) .setResultTransformer(Transformers.aliasToBean(ChequeFromContactPayrollFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.like("this.serial", filterModel.getSerial() + "%")); }/*from w w w. jav a 2s . co m*/ if (isNotEmpty(filterModel.getReference())) { crit.add(Restrictions.like("this.reference", filterModel.getReference() + "%")); } if (isNotEmpty(filterModel.getCode())) { crit.add(Restrictions.like("this.code", filterModel.getCode() + "%")); } if (isNotEmpty(filterModel.getContactCode())) { crit.add(Restrictions.ilike("contact.code", filterModel.getContactCode(), MatchMode.START)); } if (isNotEmpty(filterModel.getContactName())) { crit.add(Restrictions.ilike("contact.fullname", filterModel.getContactName(), MatchMode.ANYWHERE)); } if (filterModel.getBeginDate() != null) { crit.add(Restrictions.ge("this.date", filterModel.getBeginDate())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("this.date", filterModel.getEndDate())); } crit.addOrder(Order.desc("this.date")); crit.addOrder(Order.desc("this.serial")); return crit; }
From source file:com.ut.tekir.finance.ChequeSuggestionBean.java
License:LGPL
@SuppressWarnings("unchecked") public List<Cheque> selectChequeList() { HibernateSessionProxy session = (HibernateSessionProxy) entityManager.getDelegate(); DetachedCriteria crit = DetachedCriteria.forClass(Cheque.class); //TODO: projection saglanmali, embedded money nesnesi sorun cikariyor // crit.forClass(Money.class, "money"); // crit.setProjection(Projections.projectionList() // .add(Projections.property("id"), "id") // .add(Projections.property("maturityDate"), "maturityDate") // .add(Projections.property("referenceNo"), "referenceNo") // .add(Projections.property("bankName"), "bankName") // .add(Projections.property("bankBranch"), "bankBranch") // .add(Projections.property("accountNo"), "accountNo") // .add(Projections.property("chequeOwner"), "chequeOwner") // .add(Projections.property("contact"), "contact") // .add(Projections.property("lastStatus"), "lastStatus") // .add(Projections.property("previousStatus"), "previousStatus") // .add(Projections.property("serialNo"), "serialNo")); // /* ww w. j a v a2 s . c om*/ // crit.setResultTransformer(Transformers.aliasToBean(Cheque.class)); if (getHistoryBeginDate() != null || getHistoryEndDate() != null) { crit.createAlias("history", "history"); if (getHistoryBeginDate() != null) { crit.add(Restrictions.ge("history.date", getHistoryBeginDate())); } if (getHistoryEndDate() != null) { crit.add(Restrictions.le("history.date", getHistoryEndDate())); } crit.add(Restrictions.eqProperty("history.status", "this.lastStatus")); } if (getReferenceNo() != null && getReferenceNo().length() > 0) { crit.add(Restrictions.ilike("referenceNo", getReferenceNo(), MatchMode.ANYWHERE)); } if (getSerialNo() != null && getSerialNo().length() > 0) { crit.add(Restrictions.ilike("serialNo", getSerialNo(), MatchMode.START)); } if (getBeginDate() != null) { crit.add(Restrictions.ge("maturityDate", getBeginDate())); } if (getEndDate() != null) { crit.add(Restrictions.le("maturityDate", getEndDate())); } if (getBankName() != null && getBankName().length() > 0) { crit.add(Restrictions.ilike("bankName", getBankName(), MatchMode.START)); } if (getBankBranch() != null && getBankBranch().length() > 0) { crit.add(Restrictions.ilike("bankBranch", getBankBranch(), MatchMode.START)); } if (getChequeOwner() != null && getChequeOwner().length() > 0) { crit.add(Restrictions.ilike("chequeOwner", getChequeOwner(), MatchMode.START)); } if (getBankBranch() != null && getBankBranch().length() > 0) { crit.add(Restrictions.ilike("bankBranch", getBankBranch(), MatchMode.START)); } if (getBankAccount() != null && getBankAccount().length() > 0) { crit.add(Restrictions.ilike("bankAccount", getBankAccount(), MatchMode.START)); } if (getBankAccountId() != null) { crit.add(Restrictions.eq("bankAccountId", getBankAccountId().getId())); } if (getContact() != null) { crit.add(Restrictions.eq("contact", getContact())); } if (lastStatus != null) { crit.add(Restrictions.eq("lastStatus", lastStatus)); } else { List<ChequeStatus> possibleStatus = null; if (clientCheque != null && clientCheque.equals(Boolean.TRUE)) { possibleStatus = possibleStatusForCustomer(targetStatus); } else { possibleStatus = possibleStatusForFirm(targetStatus); } if (possibleStatus != null) { crit.add(Restrictions.in("lastStatus", possibleStatus)); } } crit.add(Restrictions.eq("clientCheque", getClientCheque())); Criteria ecrit = crit.getExecutableCriteria(session); chequeList = ecrit.list(); return chequeList; }
From source file:com.ut.tekir.finance.ChequeToAccountCollectionPayrollBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(ChequeToAccountCollectionPayroll.class); crit.createAlias("this.account", "account"); crit.setProjection(Projections.projectionList().add(Projections.property("this.id"), "id") .add(Projections.property("this.serial"), "serial") .add(Projections.property("this.reference"), "reference") .add(Projections.property("this.code"), "code").add(Projections.property("this.date"), "date") .add(Projections.property("this.info"), "info") .add(Projections.property("account.name"), "accountName")) .setResultTransformer(Transformers.aliasToBean(ChequeToAccountCollectionPayrollFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }/*w w w . ja v a 2s . co m*/ if (isNotEmpty(filterModel.getReference())) { crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START)); } if (isNotEmpty(filterModel.getCode())) { crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START)); } if (filterModel.getBeginDate() != null) { crit.add(Restrictions.ge("this.date", filterModel.getBeginDate())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("this.date", filterModel.getEndDate())); } if (filterModel.getAccount() != null) { crit.add(Restrictions.eq("this.account", filterModel.getAccount())); } crit.addOrder(Order.desc("this.date")); return crit; }
From source file:com.ut.tekir.finance.ChequeToAccountPaymentPayrollBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(ChequeToAccountPaymentPayroll.class); crit.createAlias("this.account", "account"); crit.setProjection(Projections.projectionList().add(Projections.property("this.id"), "id") .add(Projections.property("this.serial"), "serial") .add(Projections.property("this.reference"), "reference") .add(Projections.property("this.code"), "code").add(Projections.property("this.date"), "date") .add(Projections.property("this.info"), "info") .add(Projections.property("account.name"), "accountName")) .setResultTransformer(Transformers.aliasToBean(ChequeToAccountPaymentPayrollFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }//from w ww. j a va 2s . c o m if (isNotEmpty(filterModel.getReference())) { crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START)); } if (isNotEmpty(filterModel.getCode())) { crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START)); } if (filterModel.getBeginDate() != null) { crit.add(Restrictions.ge("this.date", filterModel.getBeginDate())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("this.date", filterModel.getEndDate())); } if (filterModel.getAccount() != null) { crit.add(Restrictions.eq("this.account", filterModel.getAccount())); } crit.addOrder(Order.desc("this.date")); crit.addOrder(Order.desc("this.serial")); return crit; }
From source file:com.ut.tekir.finance.ChequeToBankAssurancePayrollBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(ChequeToBankAssurancePayroll.class); crit.createAlias("this.bank", "bank"); crit.createAlias("this.bankBranch", "bankBranch"); crit.createAlias("this.bankAccount", "bankAccount"); crit.setProjection(Projections.projectionList().add(Projections.property("this.id"), "id") .add(Projections.property("this.serial"), "serial") .add(Projections.property("this.reference"), "reference") .add(Projections.property("this.code"), "code").add(Projections.property("this.date"), "date") .add(Projections.property("this.info"), "info").add(Projections.property("bank.name"), "bankName") .add(Projections.property("bankBranch.name"), "bankBranchName") .add(Projections.property("bankAccount.name"), "bankAccountName")) .setResultTransformer(Transformers.aliasToBean(ChequeToBankAssurancePayrollFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }/* w w w . j a v a 2 s .co m*/ if (isNotEmpty(filterModel.getReference())) { crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START)); } if (isNotEmpty(filterModel.getCode())) { crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START)); } if (filterModel.getBeginDate() != null) { crit.add(Restrictions.ge("this.date", filterModel.getBeginDate())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("this.date", filterModel.getEndDate())); } if (filterModel.getBank() != null) { crit.add(Restrictions.eq("this.bank", filterModel.getBank())); } if (filterModel.getBankBranch() != null) { crit.add(Restrictions.eq("this.bankBranch", filterModel.getBankBranch())); } if (filterModel.getBankAccount() != null) { crit.add(Restrictions.eq("this.bankAccount", filterModel.getBankAccount())); } crit.addOrder(Order.desc("this.date")); crit.addOrder(Order.desc("this.serial")); return crit; }
From source file:com.ut.tekir.finance.ChequeToBankPaymentPayrollBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(ChequeToBankPaymentPayroll.class); crit.createAlias("this.bank", "bank"); crit.createAlias("this.bankBranch", "bankBranch"); crit.createAlias("this.bankAccount", "bankAccount"); crit.setProjection(Projections.projectionList().add(Projections.property("this.id"), "id") .add(Projections.property("this.serial"), "serial") .add(Projections.property("this.reference"), "reference") .add(Projections.property("this.code"), "code").add(Projections.property("this.date"), "date") .add(Projections.property("this.info"), "info").add(Projections.property("this.bank"), "bank") .add(Projections.property("this.bankBranch"), "bankBranch") .add(Projections.property("this.bankAccount"), "bankAccount")) .setResultTransformer(Transformers.aliasToBean(ChequeToBankPaymentPayrollFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }//ww w. jav a 2 s . c o m if (isNotEmpty(filterModel.getReference())) { crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START)); } if (isNotEmpty(filterModel.getCode())) { crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START)); } if (filterModel.getBeginDate() != null) { crit.add(Restrictions.ge("this.date", filterModel.getBeginDate())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("this.date", filterModel.getEndDate())); } if (filterModel.getBank() != null) { crit.add(Restrictions.eq("this.bank", filterModel.getBank())); } if (filterModel.getBankBranch() != null) { crit.add(Restrictions.eq("this.bankBranch", filterModel.getBankBranch())); } if (filterModel.getBankAccount() != null) { crit.add(Restrictions.eq("this.bankAccount", filterModel.getBankAccount())); } crit.addOrder(Order.desc("this.date")); crit.addOrder(Order.desc("this.serial")); return crit; }
From source file:com.ut.tekir.finance.ChequeToBankPayrollBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(ChequeToBankPayroll.class); crit.createAlias("this.bank", "bank"); crit.createAlias("this.bankBranch", "bankBranch"); crit.createAlias("this.bankAccount", "bankAccount"); crit.setProjection(Projections.projectionList().add(Projections.property("this.id"), "id") .add(Projections.property("this.serial"), "serial") .add(Projections.property("this.reference"), "reference") .add(Projections.property("this.code"), "code").add(Projections.property("this.date"), "date") .add(Projections.property("this.info"), "info").add(Projections.property("bank.name"), "bankName") .add(Projections.property("bankBranch.name"), "bankBranchName") .add(Projections.property("bankAccount.name"), "bankAccountName")) .setResultTransformer(Transformers.aliasToBean(ChequeToBankPayrollFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }/*from w w w .j a va 2s . co m*/ if (isNotEmpty(filterModel.getReference())) { crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START)); } if (isNotEmpty(filterModel.getCode())) { crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START)); } if (filterModel.getBeginDate() != null) { crit.add(Restrictions.ge("this.date", filterModel.getBeginDate())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("this.date", filterModel.getEndDate())); } if (filterModel.getBank() != null) { crit.add(Restrictions.eq("this.bank", filterModel.getBank())); } if (filterModel.getBankBranch() != null) { crit.add(Restrictions.eq("this.bankBranch", filterModel.getBankBranch())); } if (filterModel.getBankAccount() != null) { crit.add(Restrictions.eq("this.bankAccount", filterModel.getBankAccount())); } crit.addOrder(Order.desc("this.date")); return crit; }
From source file:com.ut.tekir.finance.ChequeToContactPayrollBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(ChequeToContactPayroll.class); crit.createAlias("contact", "contact"); crit.setProjection(Projections.projectionList().add(Projections.property("this.id"), "id") .add(Projections.property("this.serial"), "serial") .add(Projections.property("this.reference"), "reference") .add(Projections.property("this.code"), "code").add(Projections.property("this.date"), "date") .add(Projections.property("this.info"), "info") .add(Projections.property("contact.code"), "contactCode") .add(Projections.property("contact.person"), "person") .add(Projections.property("contact.company"), "company") .add(Projections.property("contact.name"), "contactName")) .setResultTransformer(Transformers.aliasToBean(ChequeToContactPayrollFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }//from ww w . j ava2 s . c om if (isNotEmpty(filterModel.getReference())) { crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START)); } if (isNotEmpty(filterModel.getCode())) { crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START)); } if (isNotEmpty(filterModel.getContactName())) { crit.add(Restrictions.ilike("contact.name", "%" + filterModel.getContactName(), MatchMode.START)); } if (isNotEmpty(filterModel.getContactCode())) { crit.add(Restrictions.ilike("contact.code", "%" + filterModel.getContactCode(), MatchMode.START)); } if (filterModel.getBeginDate() != null) { crit.add(Restrictions.ge("this.date", filterModel.getBeginDate())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("this.date", filterModel.getEndDate())); } crit.addOrder(Order.desc("this.date")); crit.addOrder(Order.desc("this.serial")); return crit; }
From source file:com.ut.tekir.finance.CollectionBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(Payment.class); crit.createAlias("this.contact", "contact"); crit.createAlias("this.account", "account"); ProjectionList pl = Projections.projectionList(); pl.add(Projections.property("this.id"), "id").add(Projections.property("this.serial"), "serial") .add(Projections.property("this.reference"), "reference") .add(Projections.property("this.code"), "code").add(Projections.property("this.date"), "date") .add(Projections.property("this.info"), "info") .add(Projections.property("contact.code"), "contactCode") .add(Projections.property("contact.fullname"), "contactName") .add(Projections.property("contact.company"), "company") .add(Projections.property("contact.person"), "person") .add(Projections.property("account.code"), "accountCode") .add(Projections.property("this.totalAmount.currency"), "totalAmountCurrency") .add(Projections.property("this.totalAmount.value"), "totalAmountValue"); if (filterModel.getWorkBunch() != null) { crit.createAlias("this.items", "it", CriteriaSpecification.LEFT_JOIN); pl.add(Projections.property("it.workBunch"), "workBunch"); pl.add(Projections.property("it.amount.value"), "itemAmountValue"); crit.add(Restrictions.eq("it.workBunch", filterModel.getWorkBunch())); }//from w w w.j a v a2 s.c o m crit.setProjection(pl).setResultTransformer(Transformers.aliasToBean(PaymentFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); } if (isNotEmpty(filterModel.getReference())) { crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START)); } if (isNotEmpty(filterModel.getCode())) { crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START)); } if (filterModel.getBeginDate() != null) { crit.add(Restrictions.ge("this.date", filterModel.getBeginDate())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("this.date", filterModel.getEndDate())); } if (isNotEmpty(filterModel.getContactCode())) { crit.add(Restrictions.ilike("contact.code", filterModel.getContactCode(), MatchMode.START)); } if (isNotEmpty(filterModel.getContactName())) { crit.add(Restrictions.ilike("contact.fullname", filterModel.getContactName(), MatchMode.START)); } if (filterModel.getProcessType() != null) { crit.add(Restrictions.eq("this.processType", filterModel.getProcessType())); } crit.add(Restrictions.eq("this.action", FinanceAction.Credit)); crit.addOrder(Order.desc("this.date")); crit.addOrder(Order.desc("this.serial")); return crit; }
From source file:com.ut.tekir.finance.ContactToBankTransferBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(BankToContactTransfer.class); crit.createAlias("contact", "contact"); crit.setProjection(Projections.projectionList().add(Projections.property("id"), "id") .add(Projections.property("serial"), "serial").add(Projections.property("reference"), "reference") .add(Projections.property("code"), "code").add(Projections.property("bankAccount"), "bankAccount") .add(Projections.property("bankBranch"), "bankBranch").add(Projections.property("bank"), "bank") .add(Projections.property("contact.fullname"), "contactName") .add(Projections.property("contact.code"), "contactCode") .add(Projections.property("contact.company"), "company") .add(Projections.property("contact.person"), "person").add(Projections.property("date"), "date") .add(Projections.property("info"), "info") .add(Projections.property("this.amount.value"), "amountValue") .add(Projections.property("this.amount.currency"), "amountCurrency") .add(Projections.property("this.cost.value"), "costValue") .add(Projections.property("this.cost.currency"), "costCurrency")) .setResultTransformer(Transformers.aliasToBean(ContactToBankTransferFilterModel.class)); if (filterModel.getWorkBunch() != null) { crit.add(Restrictions.eq("this.workBunch", filterModel.getWorkBunch())); }// ww w.ja v a 2s .com if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); } if (isNotEmpty(filterModel.getReference())) { crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START)); } if (isNotEmpty(filterModel.getCode())) { crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START)); } if (filterModel.getBeginDate() != null) { crit.add(Restrictions.ge("this.date", filterModel.getBeginDate())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("this.date", filterModel.getEndDate())); } if (isNotEmpty(filterModel.getContactName())) { crit.add(Restrictions.ilike("contact.fullname", filterModel.getContactName(), MatchMode.START)); } if (isNotEmpty(filterModel.getContactCode())) { crit.add(Restrictions.ilike("contact.code", filterModel.getContactCode(), MatchMode.START)); } if (filterModel.getBank() != null) { crit.add(Restrictions.eq("this.bank", filterModel.getBank())); } if (filterModel.getBankBranch() != null) { crit.add(Restrictions.eq("this.bankBranch", filterModel.getBankBranch())); } if (filterModel.getBankAccount() != null) { crit.add(Restrictions.eq("this.bankAccount", filterModel.getBankAccount())); } if (filterModel.getTransferType() != BankTransferType.Unknown) { crit.add(Restrictions.eq("this.transferType", filterModel.getTransferType())); } if (filterModel.getProcessType() != null) { crit.add(Restrictions.eq("this.processType", filterModel.getProcessType())); } crit.add(Restrictions.eq("action", FinanceAction.Credit)); crit.addOrder(Order.desc("this.date")); crit.addOrder(Order.desc("this.serial")); return crit; }