List of usage examples for org.hibernate.criterion DetachedCriteria createAlias
public DetachedCriteria createAlias(String associationPath, String alias)
From source file:com.ut.tekir.finance.PromissoryToBankPaymentPayrollBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(PromissoryToBankPaymentPayroll.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(PromissoryToBankPaymentPayrollFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }// w w w .j ava 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.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.PromissoryToBankPayrollBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(PromissoryToBankPayroll.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(PromissoryToBankPayrollFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }//ww w .j a va2 s . com 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.PromissoryToContactPayrollBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(PromissoryToContactPayroll.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.company"), "company") .add(Projections.property("contact.person"), "person") .add(Projections.property("contact.name"), "contactName")) .setResultTransformer(Transformers.aliasToBean(PromissoryToContactPayrollFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }// ww w . j a v a2 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 (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.general.PosCommisionBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(PosCommision.class); //crit.createAlias("detailList", "detailList"); crit.createAlias("pos", "pos"); crit.createAlias("pos.bank", "bank"); crit.createAlias("pos.bankBranch", "bankBranch"); crit.createAlias("pos.bankAccount", "bankAccount"); crit.setProjection(Projections.projectionList() // .add(Projections.property("detailList.month"), "month") // .add(Projections.property("detailList.rate"), "rate") // .add(Projections.property("detailList.valor"), "valor") // .add(Projections.property("detailList"), "detailList") .add(Projections.property("pos"), "pos").add(Projections.property("id"), "id") .add(Projections.property("pos.bank"), "bank") .add(Projections.property("pos.bankBranch"), "bankBranch") .add(Projections.property("pos.bankAccount"), "bankAccount") .add(Projections.property("startDate"), "startDate").add(Projections.property("endDate"), "endDate") ).setResultTransformer(Transformers.aliasToBean(PosCommisionFilterModel.class)); if (filterModel.getBank() != null) { crit.add(Restrictions.eq("pos.bank", filterModel.getBank())); }// w w w .j ava 2 s .c om if (filterModel.getBankBranch() != null) { crit.add(Restrictions.eq("pos.bankBranch", filterModel.getBankBranch())); } if (filterModel.getBankAccount() != null) { crit.add(Restrictions.eq("pos.bankAccount", filterModel.getBankAccount())); } if (filterModel.getPos() != null) { crit.add(Restrictions.eq("this.pos", filterModel.getPos())); } // if (filterModel.getMonth() != null) { // crit.add(Restrictions.eq("detailList.month", filterModel.getMonth())); // } if (filterModel.getStartDate() != null) { crit.add(Restrictions.ge("this.startDate", filterModel.getStartDate())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("this.endDate", filterModel.getEndDate())); } crit.addOrder(Order.desc("this.id")); return crit; }
From source file:com.ut.tekir.invoice.PurchaseInvoiceBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(Invoice.class); crit.createAlias("this.contact", "contact"); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("serial", filterModel.getSerial(), MatchMode.START)); }/*from w w w. j a v a 2s. c o m*/ if (isNotEmpty(filterModel.getReference())) { crit.add(Restrictions.ilike("reference", filterModel.getReference(), MatchMode.START)); } if (isNotEmpty(filterModel.getCode())) { crit.add(Restrictions.ilike("code", filterModel.getCode(), MatchMode.START)); } if (filterModel.getBeginDate() != null) { crit.add(Restrictions.ge("date", filterModel.getBeginDate())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("date", filterModel.getEndDate())); } /* if( filterModel.getWarehouse() != null ){ crit.add( Restrictions.eq("warehouse", filterModel.getWarehouse() )); } */ 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)); } crit.add(Restrictions.eq("action", TradeAction.Purchase)); crit.addOrder(Order.desc("serial")); return crit; }
From source file:com.ut.tekir.invoice.SaleInvoiceBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(Invoice.class); crit.createAlias("this.contact", "contact"); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("serial", filterModel.getSerial(), MatchMode.START)); }// www . j a v a2s . co m if (isNotEmpty(filterModel.getReference())) { crit.add(Restrictions.ilike("reference", filterModel.getReference(), MatchMode.START)); } if (isNotEmpty(filterModel.getCode())) { crit.add(Restrictions.ilike("code", filterModel.getCode(), MatchMode.START)); } if (filterModel.getBeginDate() != null) { crit.add(Restrictions.ge("date", filterModel.getBeginDate())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("date", filterModel.getEndDate())); } /* if( filterModel.getWarehouse() != null ){ crit.add( Restrictions.eq("warehouse", filterModel.getWarehouse() )); } */ 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)); } crit.add(Restrictions.eq("action", TradeAction.Sale)); crit.addOrder(Order.desc("serial")); return crit; }
From source file:com.ut.tekir.invoice.yeni.LimitationChecker.java
License:LGPL
public DetachedCriteria buildCriteriaForWarehouse() { DetachedCriteria crit = DetachedCriteria.forClass(ProductTxn.class); crit.createAlias("product", "product"); crit.createAlias("warehouse", "warehouse"); ProjectionList pl = Projections.projectionList(); pl.add(Projections.groupProperty("product.code"), "prodcode") .add(Projections.groupProperty("product.name"), "prodname") .add(Projections.groupProperty("product.group"), "group") .add(Projections.groupProperty("product.barcode1"), "barcode") .add(Projections.groupProperty("warehouse.code"), "warecode") .add(Projections.groupProperty("warehouse.name"), "warename") .add(Projections.sum("quantity.value"), "quantity") .add(Projections.avg("unitPrice.value"), "unitPrice") .add(Projections.sqlGroupProjection("{alias}.UNIT as unit, " + "sum( case {alias}.trade_action when 0 then {alias}.QUANTITY else 0 end ) as INQTY, " + "sum( case {alias}.trade_action when 1 then {alias}.QUANTITY else 0 end ) as OUTQTY , " + "sum( case {alias}.trade_action when 2 then {alias}.QUANTITY else 0 end ) as BUYRETQTY, " + "sum( case {alias}.trade_action when 3 then {alias}.QUANTITY else 0 end ) as SELLRETQTY, " + "sum( case {alias}.trade_action when 6 then {alias}.QUANTITY else 0 end ) as RESQTY , " + "sum( case {alias}.trade_action when 7 then {alias}.QUANTITY else 0 end ) as DELQTY ", "UNIT", new String[] { "unit", "inqty", "outqty", "buyretqty", "sellretqty", "resqty", "delqty" }, new Type[] { Hibernate.STRING, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE })); crit.setProjection(pl);/*from w w w . j a v a 2 s . c om*/ crit.add(Restrictions.eq("active", true)); //Evran kendisini toplam deerlere eklemiyoruz. if (filterModel.getDocId() != null) { crit.add(Restrictions.ne("documentId", filterModel.getDocId())); } if (filterModel.getBarcode() != null && filterModel.getBarcode().length() > 0) { Criterion criteria1 = Restrictions.eq("product.barcode1", filterModel.getBarcode()); Criterion criteria2 = Restrictions.eq("product.barcode2", filterModel.getBarcode()); Criterion criteria3 = Restrictions.eq("product.barcode3", filterModel.getBarcode()); crit.add(Restrictions.or(criteria1, Restrictions.or(criteria2, criteria3))); } if (filterModel.getProduct() != null) { crit.add(Restrictions.eq("product", filterModel.getProduct())); } crit.addOrder(Order.asc("product.name")); return crit; }
From source file:com.ut.tekir.invoice.yeni.PurchaseInvoiceBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(TekirInvoice.class); crit.createAlias("this.contact", "contact"); crit.createAlias("this.warehouse", "warehouse"); crit.setProjection(Projections.projectionList().add(Projections.property("contact"), "contact") .add(Projections.property("warehouse"), "warehouse").add(Projections.property("serial"), "serial") .add(Projections.property("reference"), "reference").add(Projections.property("code"), "code") .add(Projections.property("date"), "date").add(Projections.property("contact.code"), "contactCode") .add(Projections.property("contact.fullname"), "contactName") .add(Projections.property("tradeAction"), "tradeAction") .add(Projections.property("documentType"), "documentType").add(Projections.property("id"), "id") .add(Projections.property("info"), "info") .add(Projections.property("totalBeforeTax.localAmount"), "totalBeforeTaxLocalAmount") .add(Projections.property("totalBeforeTax.value"), "totalBeforeTaxValue") .add(Projections.property("totalBeforeTax.currency"), "totalBeforeTaxCurrency") .add(Projections.property("totalTax.localAmount"), "totalTaxLocalAmount") .add(Projections.property("totalTax.value"), "totalTaxValue") .add(Projections.property("totalTax.currency"), "totalTaxCurrency") .add(Projections.property("grandTotal.localAmount"), "grandTotalLocalAmount") .add(Projections.property("grandTotal.value"), "grandTotalValue") .add(Projections.property("grandTotal.currency"), "grandTotalCurrency") .add(Projections.property("workBunch"), "workBunch")); crit.setResultTransformer(Transformers.aliasToBean(InvoiceFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }/*from www . j av a2s.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 (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 (isNotEmpty(filterModel.getInfo())) { crit.add(Restrictions.ilike("this.info", filterModel.getInfo(), MatchMode.ANYWHERE)); } if (filterModel.getWorkBunch() != null) { crit.add(Restrictions.eq("this.workBunch", filterModel.getWorkBunch())); } if (filterModel.getReturned() != null) { if (filterModel.getReturned()) { crit.add(Restrictions.eq("this.tradeAction", TradeAction.SaleReturn)); } else { crit.add(Restrictions.eq("this.tradeAction", TradeAction.Purchase)); } } else { crit.add(Restrictions.or(Restrictions.eq("this.tradeAction", TradeAction.SaleReturn), Restrictions.eq("this.tradeAction", TradeAction.Purchase))); } crit.add(Restrictions.or(Restrictions.eq("this.documentType", DocumentType.PurchaseInvoice), Restrictions.eq("this.documentType", DocumentType.PurchaseShipmentInvoice))); crit.addOrder(Order.desc("this.date")); crit.addOrder(Order.desc("this.serial")); return crit; }
From source file:com.ut.tekir.invoice.yeni.RetailSaleInvoiceBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(TekirInvoice.class); crit.createAlias("this.contact", "contact"); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("serial", filterModel.getSerial(), MatchMode.START)); }/* w w w. jav a2 s . c o m*/ if (isNotEmpty(filterModel.getReference())) { crit.add(Restrictions.ilike("reference", filterModel.getReference(), MatchMode.START)); } if (isNotEmpty(filterModel.getCode())) { crit.add(Restrictions.ilike("code", filterModel.getCode(), MatchMode.START)); } if (filterModel.getBeginDate() != null) { crit.add(Restrictions.ge("date", filterModel.getBeginDate())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("date", filterModel.getEndDate())); } /* if( filterModel.getWarehouse() != null ){ crit.add( Restrictions.eq("warehouse", filterModel.getWarehouse() )); } */ 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)); } crit.add(Restrictions.eq("tradeAction", TradeAction.Sale)); crit.add(Restrictions.eq("documentType", DocumentType.RetailSaleShipmentInvoice)); crit.addOrder(Order.desc("serial")); return crit; }
From source file:com.ut.tekir.invoice.yeni.SaleInvoiceBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(TekirInvoice.class); crit.createAlias("this.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("date"), "date") .add(Projections.property("info"), "info").add(Projections.property("contact.code"), "contactCode") .add(Projections.property("contact.fullname"), "contactName") .add(Projections.property("contact.company"), "contactCompany") .add(Projections.property("contact.person"), "contactPerson") .add(Projections.property("documentType"), "documentType") .add(Projections.property("tradeAction"), "tradeAction") .add(Projections.property("totalBeforeTax.value"), "totalBeforeTaxValue") .add(Projections.property("totalBeforeTax.currency"), "totalBeforeTaxCurrency") .add(Projections.property("totalTax.value"), "totalTaxValue") .add(Projections.property("totalTax.currency"), "totalTaxCurrency") .add(Projections.property("grandTotal.value"), "grandTotalValue") .add(Projections.property("grandTotal.currency"), "grandTotalCurrency") .add(Projections.property("workBunch"), "workBunch")); crit.setResultTransformer(Transformers.aliasToBean(InvoiceFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }/* w w w . j ava2 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 (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 (isNotEmpty(filterModel.getInfo())) { crit.add(Restrictions.ilike("this.info", filterModel.getInfo(), MatchMode.ANYWHERE)); } if (filterModel.getActive() != null) { crit.add(Restrictions.eq("this.active", filterModel.getActive())); } if (filterModel.getWorkBunch() != null) { crit.add(Restrictions.eq("this.workBunch", filterModel.getWorkBunch())); } if (filterModel.getReturned() != null) { if (filterModel.getReturned()) { crit.add(Restrictions.eq("this.tradeAction", TradeAction.PurchseReturn)); } else { crit.add(Restrictions.eq("this.tradeAction", TradeAction.Sale)); } } else { crit.add(Restrictions.or(Restrictions.eq("this.tradeAction", TradeAction.PurchseReturn), Restrictions.eq("this.tradeAction", TradeAction.Sale))); } if (filterModel.getProformaInvoice() != null) { if (filterModel.getProformaInvoice()) { crit.add(Restrictions.eq("this.documentType", DocumentType.SaleProformaInvoice)); } else { crit.add(Restrictions.in("this.documentType", new DocumentType[] { DocumentType.SaleInvoice, DocumentType.SaleShipmentInvoice, DocumentType.RetailSaleShipmentInvoice })); } } else { crit.add(Restrictions.in("this.documentType", new DocumentType[] { DocumentType.SaleInvoice, DocumentType.SaleShipmentInvoice, DocumentType.RetailSaleShipmentInvoice, DocumentType.SaleProformaInvoice })); } crit.addOrder(Order.desc("this.date")); crit.addOrder(Order.desc("this.serial")); return crit; }