List of usage examples for org.hibernate.criterion Restrictions ilike
public static Criterion ilike(String propertyName, String value, MatchMode matchMode)
From source file:com.ut.tekir.stock.PurchaseShipmentBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(ShipmentNote.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("date"), "date") .add(Projections.property("info"), "info").add(Projections.property("warehouse"), "warehouse") .add(Projections.property("contact.fullname"), "contactName") .add(Projections.property("contact.code"), "contactCode")) .setResultTransformer(Transformers.aliasToBean(ShipmentFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("serial", filterModel.getSerial(), MatchMode.START)); }/* ww w. j av a 2 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.getContactName())) { crit.add(Restrictions.ilike("contact.fullname", filterModel.getContactName(), MatchMode.ANYWHERE)); } if (isNotEmpty(filterModel.getContactCode())) { crit.add(Restrictions.ilike("contact.code", filterModel.getContactCode(), MatchMode.START)); } crit.add(Restrictions.eq("this.action", TradeAction.Purchase)); crit.addOrder(Order.desc("this.serial")); return crit; }
From source file:com.ut.tekir.stock.SaleOrderBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(OrderNote.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("status"), "status") .add(Projections.property("date"), "date").add(Projections.property("info"), "info") .add(Projections.property("warehouse"), "warehouse") .add(Projections.property("contact.name"), "contactName") .add(Projections.property("contact.code"), "contactCode")) .setResultTransformer(Transformers.aliasToBean(OrderFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("serial", filterModel.getSerial(), MatchMode.START)); }// w w w . j av a 2s. c om 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.name", filterModel.getContactName(), MatchMode.START)); } if (filterModel.getStatus() != null) { crit.add(Restrictions.eq("status", filterModel.getStatus())); } crit.add(Restrictions.eq("action", TradeAction.Sale)); crit.addOrder(Order.desc("serial")); return crit; }
From source file:com.ut.tekir.stock.SaleShipmentBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(ShipmentNote.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("date"), "date") .add(Projections.property("info"), "info").add(Projections.property("warehouse"), "warehouse") .add(Projections.property("contact.fullname"), "contactName") .add(Projections.property("contact.code"), "contactCode")) .setResultTransformer(Transformers.aliasToBean(ShipmentFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }//www. j a v 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.getWarehouse() != null) { crit.add(Restrictions.eq("this.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.ANYWHERE)); } crit.add(Restrictions.eq("this.action", TradeAction.Sale)); crit.addOrder(Order.desc("this.serial")); return crit; }
From source file:com.ut.tekir.stock.yeni.PurchaseShipmentBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(TekirShipmentNote.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("date"), "date") .add(Projections.property("info"), "info").add(Projections.property("info1"), "info1") .add(Projections.property("info2"), "info2").add(Projections.property("warehouse"), "warehouse") .add(Projections.property("contact.fullname"), "contactName") .add(Projections.property("contact.company"), "company") .add(Projections.property("contact.person"), "person") .add(Projections.property("contact.code"), "contactCode") .add(Projections.property("workBunch"), "workBunch")) .setResultTransformer(Transformers.aliasToBean(ShipmentFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }//from w ww .j av 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 (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.getWarehouse() != null) { crit.add(Restrictions.eq("this.warehouse", filterModel.getWarehouse())); } if (isNotEmpty(filterModel.getContactName())) { crit.add(Restrictions.ilike("contact.fullname", filterModel.getContactName(), MatchMode.ANYWHERE)); } if (isNotEmpty(filterModel.getContactCode())) { crit.add(Restrictions.ilike("contact.code", filterModel.getContactCode(), MatchMode.START)); } if (filterModel.getInvoiced() != null) { if (filterModel.getInvoiced().equals(Boolean.TRUE)) { crit.add(Restrictions.isNotNull("this.invoice")); } else { crit.add(Restrictions.isNull("this.invoice")); } } if (filterModel.getWorkBunch() != null) { crit.add(Restrictions.eq("this.workBunch", filterModel.getWorkBunch())); } crit.add(Restrictions.eq("this.tradeAction", TradeAction.Purchase)); crit.addOrder(Order.desc("this.date")); crit.addOrder(Order.desc("this.serial")); return crit; }
From source file:com.ut.tekir.stock.yeni.SaleOrderBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(TekirOrderNote.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("status"), "status") .add(Projections.property("date"), "date").add(Projections.property("deliveryDate"), "deliveryDate") .add(Projections.property("info"), "info").add(Projections.property("warehouse"), "warehouse") .add(Projections.property("contact.fullname"), "contactName") .add(Projections.property("contact.code"), "contactCode") .add(Projections.property("contact.person"), "person") .add(Projections.property("contact.company"), "company") .add(Projections.property("workBunch"), "workBunch")) .setResultTransformer(Transformers.aliasToBean(OrderFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }/*w w w . j av 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.getDeliveryBeginDate() != null) { crit.add(Restrictions.ge("this.deliveryDate", filterModel.getDeliveryBeginDate())); } if (filterModel.getDeliveryEndDate() != null) { crit.add(Restrictions.le("this.deliveryDate", filterModel.getDeliveryEndDate())); } if (filterModel.getWarehouse() != null) { crit.add(Restrictions.eq("this.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.name", filterModel.getContactName(), MatchMode.START)); } if (filterModel.getStatus() != null) { crit.add(Restrictions.eq("this.status", filterModel.getStatus())); } if (filterModel.getWorkBunch() != null) { crit.add(Restrictions.eq("this.workBunch", filterModel.getWorkBunch())); } crit.add(Restrictions.eq("this.tradeAction", TradeAction.Sale)); crit.addOrder(Order.desc("this.serial")); return crit; }
From source file:com.ut.tekir.stock.yeni.SaleShipmentBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(TekirShipmentNote.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("date"), "date") .add(Projections.property("info1"), "info1").add(Projections.property("info2"), "info2") .add(Projections.property("warehouse"), "warehouse") .add(Projections.property("contact.fullname"), "contactName") .add(Projections.property("contact.company"), "company") .add(Projections.property("contact.person"), "person") .add(Projections.property("contact.code"), "contactCode") .add(Projections.property("workBunch"), "workBunch")) .setResultTransformer(Transformers.aliasToBean(ShipmentFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }/*from ww w .ja va 2s . 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 (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.getWarehouse() != null) { crit.add(Restrictions.eq("this.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.ANYWHERE)); } if (filterModel.getInvoiced() != null) { if (filterModel.getInvoiced().equals(Boolean.TRUE)) { crit.add(Restrictions.isNotNull("this.invoice")); } else { crit.add(Restrictions.isNull("this.invoice")); } } if (filterModel.getWorkBunch() != null) { crit.add(Restrictions.eq("this.workBunch", filterModel.getWorkBunch())); } crit.add(Restrictions.eq("this.tradeAction", TradeAction.Sale)); crit.addOrder(Order.desc("this.date")); crit.addOrder(Order.desc("this.serial")); return crit; }
From source file:com.ut.tekir.tender.TenderBrowseBean.java
License:LGPL
private void addRestrictions(DetachedCriteria crit) { if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }//w w w .ja v a 2 s . co m if (isNotEmpty(filterModel.getReference())) { crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START)); } if (filterModel.getStatus() != null) { crit.add(Restrictions.eq("this.status", filterModel.getStatus())); } 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())); } }
From source file:com.vaadin.data.hbnutil.filter.StringContainerFilter.java
License:Open Source License
public Criterion getFieldCriterion(String fullPropertyName) { return (ignoreCase) ? Restrictions.ilike(fullPropertyName, filterString, onlyMatchPrefix ? MatchMode.START : MatchMode.ANYWHERE) : Restrictions.like(fullPropertyName, filterString, onlyMatchPrefix ? MatchMode.START : MatchMode.ANYWHERE); }
From source file:com.vektorel.hrapp.service.taner.KullaniciService.java
@Override public List<Kullanici> getAll(String query) { Session session = HibernateUtil.getSessionFactory().openSession(); Criteria criteria = session.createCriteria(Kullanici.class); if (query != null) { // select * from kullanici where ad_soyad like '%KARA%' or username like '%KARA%' criteria.add(Restrictions.or(Restrictions.ilike("username", query, MatchMode.ANYWHERE), Restrictions.ilike("adSoyad", query, MatchMode.ANYWHERE))); }//from ww w .j a va 2 s. c o m criteria.addOrder(Order.asc("id")); return criteria.list(); }
From source file:com.vgorcinschi.concordiafootballmanager.data.H2PlayerRepository.java
@Override @Transactional//from w w w . ja v a 2s.co m public Player findByLastName(String lastName) { try { return (Player) currentSession().createCriteria(Player.class) .add(Restrictions.ilike("lastName", lastName, MatchMode.ANYWHERE)).uniqueResult(); } catch (EmptyResultDataAccessException e) { throw new PlayerNotFoundException(lastName); } }