List of usage examples for org.hibernate.criterion Example ignoreCase
public Example ignoreCase()
From source file:br.com.arsmachina.dao.hibernate.ReadableDAOImpl.java
License:Apache License
/** * Used by {@link #findByExample(Object)} to create an {@link Example} instance. * // w w w . ja v a 2s. c o m * @todo add criteria for property types not handled by Example (primary keys, associations, * etc) * @return an {@link Example}. */ public Example createExample(T entity) { Example example = Example.create(entity); example.enableLike(MatchMode.ANYWHERE); example.excludeZeroes(); example.ignoreCase(); return example; }
From source file:br.com.hslife.imobiliaria.dao.impl.HibernateGenericDao.java
License:Open Source License
@Override public List listByExample(Object example) { HibernateUtility.getSession().clear(); Criteria criteria = HibernateUtility.getSession().createCriteria(example.getClass()); Example sample = Example.create(example); sample.enableLike(MatchMode.ANYWHERE); sample.ignoreCase(); criteria.add(sample);// w w w . ja v a2 s.c o m return criteria.list(); }
From source file:br.com.reindex.suri.framework.dao.DaoSupport.java
License:Open Source License
/** * Metodo responsavel por recuperar todos os objetos de uma tabela da base de dados de acordo * com o exemplo passado. /*w w w . j av a2 s . c o m*/ * * @param filtro * @param matchMode * @param ignoreCase * @return lista */ public List<T> retrieveByExample(T filtro, MatchMode matchMode, boolean ignoreCase) { Example example = Example.create(filtro); if (matchMode != null) { example = example.enableLike(matchMode); } if (ignoreCase) { example = example.ignoreCase(); } return getSession().createCriteria(tipo).add(example).list(); }
From source file:br.com.suricattus.surispring.framework.service.GenericRetrieveService.java
License:Open Source License
/** * Retorna a lista de entidades filtradas pelos parametros informados * @param <T>/* w ww . java 2 s.c om*/ * @param classe * @param filtro * @param matchMode * @param ignoreCase * @return lista de entidades */ @SuppressWarnings("unchecked") public <T> List<T> retrieveByExample(Class<T> classe, T filtro, MatchMode matchMode, boolean ignoreCase) { Example example = Example.create(filtro); if (matchMode != null) example = example.enableLike(matchMode); if (ignoreCase) example = example.ignoreCase(); return getSession().createCriteria(classe).add(example).list(); }
From source file:br.com.suricattus.surispring.framework.service.GenericRetrieveService.java
License:Open Source License
/** * Retorna a entidade filtrada pelos parametros informados * @param <T>// w w w.j a v a 2 s .c o m * @param classe * @param filtro * @param matchMode * @param ignoreCase * @return lista de entidades */ @SuppressWarnings("unchecked") public <T> T retrieveUniqueByExample(Class<T> classe, T filtro, MatchMode matchMode, boolean ignoreCase) { Example example = Example.create(filtro); if (matchMode != null) example = example.enableLike(matchMode); if (ignoreCase) example = example.ignoreCase(); return (T) getSession().createCriteria(classe).add(example).uniqueResult(); }
From source file:br.com.tcc.service.persistence.CriteriaHelper.java
/** * Cria um exemplo da etidade para buscas. O padro de buscas por exemplo do framework Celula Tronco Java segue os seguintes termos: * <ol>/*from www. java2 s . c o m*/ * <li> Case igonorado para propriedades String</li> * <li>O operador "like" habilitado para todos os atributos String, buscando o termo em qualquer parte da String.</li> * <li>PropertySelector ser {@link NotNullOrBlankProperySelector}.</li> * </ol> * @param <T> Tipo de Entidade * @param entity entidade * @return exemplo de T */ public static <T extends IEntity<? extends Serializable>> Example createExample(final T entity) { final Example example = Example.create(entity); example.ignoreCase(); example.enableLike(MatchMode.ANYWHERE); example.setPropertySelector(NotNullOrBlankProperySelector.getInstance()); return example; }
From source file:com.emergya.persistenceGeo.dao.impl.MultiSirDatabaseGenericHibernateDAOImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from ww w. j a va 2s .c o m public List<T> findByExample(T exampleInstance, String[] excludedProperties, boolean ignoreCase) { DetachedCriteria crit = DetachedCriteria.forClass(persistentClass); Example example = Example.create(exampleInstance); if (excludedProperties != null) { for (String exclude : excludedProperties) { example.excludeProperty(exclude); } } if (ignoreCase) { crit.add(example.ignoreCase()); } else { crit.add(example); } return getHibernateTemplate().findByCriteria(crit); }
From source file:com.github.javarch.persistence.orm.hibernate.DefaultHibernateRepository.java
License:Apache License
/** * Mtodo utilizado para criar o objeto Example. Este objeto utilizado * para realizar a busca por exemplo./*from ww w.java 2 s . c om*/ * * @param objeto * sobre o qual o Example ser criado * @return em objeto do tipo Example */ protected Example createExemple(Object objeto) { Example example = Example.create(objeto); example.enableLike(MatchMode.ANYWHERE); example.excludeZeroes(); example.ignoreCase(); return example; }
From source file:com.miranteinfo.seam.framework.service.GenericRetrieveService.java
License:Open Source License
/** * Retorna a lista de entidades filtradas pelos parametros informados * @param <T>/*from w w w. ja v a 2 s.com*/ * @param classe * @param filtro * @param matchMode * @param ignoreCase * @return lista de entidades */ public <T extends BaseEntity> List<T> retrieveByExample(Class<T> classe, BaseEntity filtro, MatchMode matchMode, boolean ignoreCase) { Example example = Example.create(filtro); if (matchMode != null) { example = example.enableLike(matchMode); } if (ignoreCase) { example = example.ignoreCase(); } return getSession().createCriteria(classe).add(example).list(); }
From source file:com.viettel.model.GenericHibernateDAO.java
License:Open Source License
/** * find by Example with enableLike and ignoreCase options This method may * throw a HibernateException/*from ww w .ja v a 2 s. c o m*/ * * @param sessionName Name of hibernate session * @param exampleInstance a object to make find conditions * @param enableLike Use the "like" operator for all string-valued * properties * @param ignoreCase Ignore case for all string-valued properties * @param excludeProperty Exclude a particular named property * @return List of entity that match conditions */ @SuppressWarnings("unchecked") public List<T> findByExample(String sessionName, T exampleInstance, boolean enableLike, boolean ignoreCase, String... excludeProperty) { try { Criteria crit = getSession(sessionName).createCriteria(getPersistentClass()); Example example = Example.create(exampleInstance); for (String exclude : excludeProperty) { example.excludeProperty(exclude); } if (enableLike) { example.enableLike(MatchMode.ANYWHERE); } if (ignoreCase) { example.ignoreCase(); } crit.add(example); return crit.list(); } catch (RuntimeException e) { throw e; } finally { this.releaseResource(); } }