List of usage examples for org.hibernate.criterion Example excludeNone
public Example excludeNone()
From source file:com.wavemaker.runtime.data.task.SearchTask.java
License:Open Source License
private static void addExample(Object o, Criteria c, QueryOptions options) { Example e = Example.create(o); c.add(e);//from www . j a v a 2 s . c o m if (DataServiceLoggers.taskLogger.isDebugEnabled()) { DataServiceLoggers.taskLogger.debug("Added example for " + ObjectUtils.objectToString(o)); } if (options.getTypedMatchMode() != null) { e.enableLike(options.getTypedMatchMode()); } if (options.getExcludeNone()) { e.excludeNone(); } if (options.getExcludeZeros()) { e.excludeZeroes(); } if (options.getIgnoreCase()) { e.ignoreCase(); } }
From source file:gov.nih.nci.caarray.dao.AbstractCaArrayDaoImpl.java
License:BSD License
Criterion createExample(Object entity, MatchMode matchMode, boolean excludeNulls, boolean excludeZeroes, Collection<String> excludeProperties) { final Example example = Example.create(entity).enableLike(matchMode).ignoreCase(); if (excludeZeroes) { example.excludeZeroes();/*from w w w. j av a 2 s . c o m*/ } else if (!excludeNulls) { example.excludeNone(); } for (final String property : excludeProperties) { example.excludeProperty(property); } // ID property is not handled by Example, so we have to special case it final PersistentClass pclass = getClassMapping(entity.getClass()); Object idVal = null; if (pclass != null && pclass.hasIdentifierProperty()) { try { idVal = PropertyUtils.getProperty(entity, pclass.getIdentifierProperty().getName()); } catch (final Exception e) { LOG.warn("Could not retrieve identifier value in a by example query, ignoring it", e); } } if (idVal == null) { return example; } else { return Restrictions.and(Restrictions.idEq(idVal), example); } }