List of usage examples for org.hibernate.criterion Restrictions ne
public static SimpleExpression ne(String propertyName, Object value)
From source file:org.hoteia.qalingo.core.dao.ProductDao.java
License:Apache License
public List<ProductMarketing> findProductMarketingsNotInThisVirtualCatalogCategoryId(final Long categoryId, Object... params) {// www. j a v a 2 s.c om Criteria criteria = createDefaultCriteria(ProductMarketing.class); handleSpecificProductMarketingFetchMode(criteria, params); criteria.createAlias("productSkus", "productSku", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("productSku.catalogCategoryVirtualProductSkuRels", "catalogCategoryProductSkuRel", JoinType.LEFT_OUTER_JOIN); criteria.add(Restrictions.ne("catalogCategoryProductSkuRel.pk.catalogCategoryVirtual.id", categoryId)); criteria.addOrder(Order.asc("id")); @SuppressWarnings("unchecked") List<ProductMarketing> productMarketings = criteria.list(); return productMarketings; }
From source file:org.hsqldb.hibernate.geomajas.layer.hibernate.CriteriaVisitor.java
License:Open Source License
/** {@inheritDoc} */ public Object visit(PropertyIsNotEqualTo filter, Object userData) { String propertyName = getPropertyName(filter.getExpression1()); String finalName = parsePropertyName(propertyName, userData); Object value = castLiteral(getLiteralValue(filter.getExpression2()), propertyName); return Restrictions.ne(finalName, value); }
From source file:org.i4change.app.data.user.daos.UserDaoImpl.java
/** * suche eines Bentzers/*from ww w .java 2 s .c om*/ * * @param user_level * @param searchstring * @param max * @param start * @return */ public List<Users> searchUser(long user_level, String searchcriteria, String searchstring, int max, int start, String orderby, boolean asc) { if (AuthLevelmanagement.checkAdminLevel(user_level)) { try { Criteria crit = getSession().createCriteria(Users.class); crit.add(Restrictions.ilike(searchcriteria, "%" + searchstring + "%")); if (asc) crit.addOrder(Order.asc(orderby)); else crit.addOrder(Order.desc(orderby)); crit.add(Restrictions.ne("deleted", "true")); crit.setMaxResults(max); crit.setFirstResult(start); List<Users> contactsZ = crit.list(); return contactsZ; } catch (HibernateException ex) { log.error(ex); } catch (Exception ex2) { log.error(ex2); } } return null; }
From source file:org.infoscoop.dao.OAuthConsumerDAO.java
License:Open Source License
public Boolean validateConsumerByIdAndServiceAndURL(String id, String serviceName, String gadgetUrl) { // Refactoring: create hibernate object (mapping? criteria? and o) Iterator results = super.getHibernateTemplate() .findByCriteria(DetachedCriteria.forClass(OAuthConsumerProp.class, "ocp") .createAlias("OAuthGadgetUrl", "ogu", CriteriaSpecification.LEFT_JOIN) .add(Restrictions.conjunction().add(Restrictions.ne("ocp.Id", id)) .add(Restrictions.eq("ocp.ServiceName", serviceName)) .add(Restrictions.eq("ogu.GadgetUrlKey", Crypt.getHash(gadgetUrl))))) .iterator();//from w w w. j a v a 2 s. c om if (results.hasNext()) { // if same contents are had, database is not updated. return true; } return false; }
From source file:org.iternine.jeppetto.dao.hibernate.HibernateQueryModelDAO.java
License:Apache License
@Override public Condition buildCondition(String conditionField, ConditionType conditionType, Iterator argsIterator) { Condition condition = new Condition(); condition.setField(conditionField);/*from w ww . j a v a 2 s . c o m*/ switch (conditionType) { case Between: condition.setConstraint(Restrictions.between(conditionField, argsIterator.next(), argsIterator.next())); break; case Equal: condition.setConstraint(Restrictions.eq(conditionField, argsIterator.next())); break; case GreaterThan: condition.setConstraint(Restrictions.gt(conditionField, argsIterator.next())); break; case GreaterThanEqual: condition.setConstraint(Restrictions.ge(conditionField, argsIterator.next())); break; case IsNotNull: condition.setConstraint(Restrictions.isNotNull(conditionField)); break; case IsNull: condition.setConstraint(Restrictions.isNull(conditionField)); break; case LessThan: condition.setConstraint(Restrictions.lt(conditionField, argsIterator.next())); break; case LessThanEqual: condition.setConstraint(Restrictions.le(conditionField, argsIterator.next())); break; case NotEqual: condition.setConstraint(Restrictions.ne(conditionField, argsIterator.next())); break; case NotWithin: condition.setConstraint( Restrictions.not(Restrictions.in(conditionField, (Collection) argsIterator.next()))); break; case Within: condition.setConstraint(Restrictions.in(conditionField, (Collection) argsIterator.next())); break; } return condition; }
From source file:org.jasig.ssp.dao.external.ExternalCourseRequisiteDao.java
License:Apache License
@SuppressWarnings("unchecked") public List<ExternalCourseRequisite> getRequisitesForCourse(String requiringCourseCode) { if (StringUtils.isBlank(requiringCourseCode)) { return new ArrayList<ExternalCourseRequisite>(); }//w w w . jav a 2 s .c o m Criteria criteria = this.createCriteria(); criteria.add(Restrictions.or(Restrictions.eq("requiringCourseCode", requiringCourseCode), Restrictions.and(Restrictions.eq("requiredCourseCode", requiringCourseCode), Restrictions.ne("requisiteCode", RequisiteCode.PRE)))); return (List<ExternalCourseRequisite>) criteria.list(); }
From source file:org.jason.mapmaker.server.repository.hibernate.HibernateLocationRepository.java
License:Apache License
@Override @Transactional(readOnly = true)/*from w w w . jav a 2s .c om*/ public List<Location> getLocationsByCoordinates(double lng, double lat) { Criteria locationCriteria = sessionFactory.getCurrentSession().createCriteria(Location.class); locationCriteria.add(Restrictions.le("minLat", lat)); locationCriteria.add(Restrictions.ge("maxLat", lat)); locationCriteria.add(Restrictions.le("minLng", lng)); locationCriteria.add(Restrictions.ge("maxLng", lng)); Criteria smCriteria = locationCriteria.createCriteria("shapefileMetadata"); smCriteria.add(Restrictions.ne("currentStatus", GeographyUtils.Status.NOT_AVAILABLE)); locationCriteria.addOrder(Order.asc("mtfcc")); List<Location> results = locationCriteria.list(); return results; }
From source file:org.jspresso.framework.model.persistence.hibernate.criterion.DefaultCriteriaFactory.java
License:Open Source License
/** * Complete criteria with translations.//from ww w .j a v a2 s .c om * * @param currentCriteria * the current criteria * @param translationsPath * the translations path * @param translationsAlias * the translations alias * @param property * the property * @param propertyDescriptor * the property descriptor * @param prefixedProperty * the prefixed property * @param locale * the locale * @param componentDescriptor * the component descriptor * @param queryComponent * the query component * @param context * the context */ @SuppressWarnings("unchecked") protected void completeCriteriaWithTranslations(DetachedCriteria currentCriteria, String translationsPath, String translationsAlias, Map.Entry<String, Object> property, IPropertyDescriptor propertyDescriptor, String prefixedProperty, Locale locale, IComponentDescriptor<?> componentDescriptor, IQueryComponent queryComponent, Map<String, Object> context) { if (propertyDescriptor instanceof IStringPropertyDescriptor && ((IStringPropertyDescriptor) propertyDescriptor).isTranslatable()) { String nlsOrRawValue = null; String nlsValue = (String) property.getValue(); String barePropertyName = property.getKey(); if (property.getKey().endsWith(IComponentDescriptor.NLS_SUFFIX)) { barePropertyName = barePropertyName.substring(0, barePropertyName.length() - IComponentDescriptor.NLS_SUFFIX.length()); } else { nlsOrRawValue = nlsValue; } if (nlsValue != null) { Junction translationRestriction = Restrictions.conjunction(); translationRestriction.add(createStringRestriction( ((ICollectionPropertyDescriptor<IPropertyTranslation>) componentDescriptor .getPropertyDescriptor(translationsPath)).getCollectionDescriptor() .getElementDescriptor() .getPropertyDescriptor(IPropertyTranslation.TRANSLATED_VALUE), translationsAlias + "." + IPropertyTranslation.TRANSLATED_VALUE, nlsValue, componentDescriptor, queryComponent, context)); String languagePath = translationsAlias + "." + IPropertyTranslation.LANGUAGE; translationRestriction.add(Restrictions.eq(languagePath, locale.getLanguage())); translationRestriction.add(Restrictions .eq(translationsAlias + "." + IPropertyTranslation.PROPERTY_NAME, barePropertyName)); Junction disjunction = Restrictions.disjunction(); disjunction.add(translationRestriction); if (nlsOrRawValue != null) { Junction rawValueRestriction = Restrictions.conjunction(); rawValueRestriction.add(Restrictions.disjunction().add(Restrictions.isNull(languagePath)) .add(Restrictions.ne(languagePath, locale.getLanguage()))); String rawPropertyName = barePropertyName + IComponentDescriptor.RAW_SUFFIX; rawValueRestriction .add(createStringRestriction(componentDescriptor.getPropertyDescriptor(rawPropertyName), rawPropertyName, nlsOrRawValue, componentDescriptor, queryComponent, context)); disjunction.add(rawValueRestriction); } currentCriteria.add(disjunction); } } else { completeCriteria(currentCriteria, createStringRestriction(propertyDescriptor, prefixedProperty, (String) property.getValue(), componentDescriptor, queryComponent, context)); } }
From source file:org.kaaproject.kaa.server.common.dao.impl.sql.HibernateConfigurationDao.java
License:Apache License
@Override public List<Configuration> findActualByEndpointGroupId(String groupId) { List<Configuration> configurations = null; LOG.debug("Searching actual configurations by endpoint group id [{}] ", groupId); if (isNotBlank(groupId)) { configurations = findListByCriterionWithAlias(ENDPOINT_GROUP_PROPERTY, ENDPOINT_GROUP_ALIAS, Restrictions.and(Restrictions.eq(ENDPOINT_GROUP_REFERENCE, Long.valueOf(groupId)), Restrictions.ne(STATUS_PROPERTY, UpdateStatus.DEPRECATED))); }//from w ww .j a v a 2 s . co m if (LOG.isTraceEnabled()) { LOG.trace("[{}] Search result: {}.", groupId, Arrays.toString(configurations.toArray())); } else { LOG.debug("[{}] Search result: {}.", groupId, configurations.size()); } return configurations; }
From source file:org.kaaproject.kaa.server.common.dao.impl.sql.HibernateConfigurationDao.java
License:Apache License
@Override public List<Configuration> findActualBySchemaIdAndGroupId(String schemaId, String groupId) { List<Configuration> configurations = Collections.emptyList(); LOG.debug("Searching actual configurations by configuration schema id [{}] " + "and group id [{}] ", schemaId, groupId);/*from ww w . j a v a 2 s. co m*/ if (isNotBlank(schemaId) && isNotBlank(groupId)) { Criteria criteria = getCriteria(); criteria.createAlias(CONFIGURATION_SCHEMA_PROPERTY, CONFIGURATION_SCHEMA_ALIAS); criteria.createAlias(ENDPOINT_GROUP_PROPERTY, ENDPOINT_GROUP_ALIAS); criteria.add(Restrictions.and(Restrictions.eq(ENDPOINT_GROUP_REFERENCE, Long.valueOf(groupId)), Restrictions.eq(CONFIGURATION_SCHEMA_REFERENCE, Long.valueOf(schemaId)), Restrictions.ne(STATUS_PROPERTY, UpdateStatus.DEPRECATED))); configurations = findListByCriteria(criteria); } if (LOG.isTraceEnabled()) { LOG.trace("[{},{}] Search result: {}.", schemaId, groupId, Arrays.toString(configurations.toArray())); } else { LOG.debug("[{},{}] Search result: {}.", schemaId, groupId, configurations.size()); } return configurations; }