List of usage examples for org.hibernate.criterion Restrictions ne
public static SimpleExpression ne(String propertyName, Object value)
From source file:org.generationcp.middleware.dao.LotDAO.java
License:Open Source License
public Long getAvailableLotBalance(Integer lotId) throws MiddlewareQueryException { try {//from ww w. java 2 s .c o m Lot lot = getById(lotId, false); Criteria criteria = getSession().createCriteria(Transaction.class); criteria.setProjection(Projections.sum("quantity")); criteria.add(Restrictions.eq("lot", lot)); // get all non-cancelled transactions criteria.add(Restrictions.ne("status", 9)); return (Long) criteria.uniqueResult(); } catch (HibernateException e) { throw new MiddlewareQueryException( "Error with getAvailableLotBalance(lotId=" + lotId + ") query from Lot: " + e.getMessage(), e); } }
From source file:org.generationcp.middleware.dao.MethodDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Method> getAllMethodsNotGenerative() throws MiddlewareQueryException { try {/*from w w w . j a va 2s .c o m*/ List<Integer> validMethodClasses = new ArrayList<Integer>(); validMethodClasses.addAll(Method.BULKED_CLASSES); validMethodClasses.addAll(Method.NON_BULKED_CLASSES); Criteria criteria = this.getSession().createCriteria(Method.class); criteria.add(Restrictions.ne("mtype", "GEN")); criteria.add(Restrictions.in("geneq", validMethodClasses)); criteria.addOrder(Order.asc("mname")); return criteria.list(); } catch (HibernateException e) { this.logAndThrowException( this.getLogExceptionMessage("getAllMethodsNotGenerative", "", null, e.getMessage(), "Method"), e); } return new ArrayList<Method>(); }
From source file:org.generationcp.middleware.dao.MethodDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Method> getMethodsNotGenerativeById(final List<Integer> ids) throws MiddlewareQueryException { try {/*from ww w . j a v a 2 s . c o m*/ final List<Integer> validMethodClasses = new ArrayList<>(); validMethodClasses.addAll(Method.BULKED_CLASSES); validMethodClasses.addAll(Method.NON_BULKED_CLASSES); final Criteria criteria = this.getSession().createCriteria(Method.class); criteria.add(Restrictions.ne("mtype", "GEN")); criteria.add(Restrictions.in("geneq", validMethodClasses)); if (ids.size() > 0) { criteria.add(Restrictions.in("mid", ids)); } criteria.addOrder(Order.asc("mname")); return criteria.list(); } catch (final HibernateException e) { MethodDAO.LOG.error( this.getLogExceptionMessage("getMethodsNotGenerativeById", "", null, e.getMessage(), "Method"), e); throw new MiddlewareQueryException( this.getLogExceptionMessage("getMethodsNotGenerativeById", "", null, e.getMessage(), "Method"), e); } }
From source file:org.generationcp.middleware.dao.MethodDAO.java
License:Open Source License
public List<Method> getAllMethodsNotBulkingNotGenerative() throws MiddlewareQueryException { try {/*w w w. j a va 2 s.co m*/ final Criteria criteria = this.getSession().createCriteria(Method.class); criteria.add(Restrictions.in("geneq", Method.NON_BULKED_CLASSES)); criteria.add(Restrictions.ne("mtype", "GEN")); criteria.addOrder(Order.asc("mname")); return criteria.list(); } catch (final HibernateException e) { MethodDAO.LOG.error(this.getLogExceptionMessage("getAllMethodsNotBulkingNotGenerative", "", null, e.getMessage(), "Method"), e); throw new MiddlewareQueryException(this.getLogExceptionMessage("getAllMethodsNotBulkingNotGenerative", "", null, e.getMessage(), "Method"), e); } }
From source file:org.geolatte.common.cql.hibernate.HibernateCriteriaBuilder.java
License:Open Source License
@Override public void outANeqExpr(ANeqExpr node) { String propertyAlias = createAlias(node.getLeft()); translatedExpressions.put(node, Restrictions.ne(propertyAlias, reader.parseAsPropertyType( translatedLiterals.get(node.getRight()).toString(), getPropertyPath(node.getLeft())))); }
From source file:org.geomajas.layer.hibernate.CriteriaVisitor.java
License:Open Source License
/** {@inheritDoc} */ @Override// w w w.j av a2 s . c o m 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.glite.security.voms.admin.persistence.dao.hibernate.RequestDAOHibernate.java
License:Apache License
public NewVOMembershipRequest findActiveVOMembershipRequest(RequesterInfo requester) { Criteria crit = getSession().createCriteria(NewVOMembershipRequest.class); crit.add(Restrictions.ne("status", STATUS.APPROVED)).add(Restrictions.ne("status", STATUS.REJECTED)) .createCriteria("requesterInfo") .add(Restrictions.eq("certificateSubject", requester.getCertificateSubject())) .add(Restrictions.eq("certificateIssuer", requester.getCertificateIssuer())); return (NewVOMembershipRequest) crit.uniqueResult(); }
From source file:org.glite.security.voms.admin.persistence.dao.hibernate.TaskDAOHibernate.java
License:Apache License
public List<Task> getActiveTasks() { return findByCriteria(Restrictions.ne("status", TaskStatus.COMPLETED), Restrictions.ne("status", TaskStatus.EXPIRED)); }
From source file:org.gluewine.persistence_jpa_hibernate.impl.HibernateTransactionalSessionImpl.java
License:Apache License
@Override public Criteria createCriteria(Class<?> cl, Filter filter) { Criteria cr = createCriteria(cl);// w ww .ja v a2 s. co m for (FilterLine line : filter.getLines()) { switch (line.getOperator()) { case CONTAINS: cr.add(Restrictions.like(line.getFieldName(), "%" + line.getValue() + "%")); break; case DOES_NOT_CONTAIN: cr.add(Restrictions.not(Restrictions.like(line.getFieldName(), "%" + line.getValue() + "%"))); break; case DOES_NOT_ICONTAIN: cr.add(Restrictions.not(Restrictions.ilike(line.getFieldName(), "%" + line.getValue() + "%"))); break; case EQUALS: cr.add(Restrictions.eq(line.getFieldName(), line.getValue())); break; case GREATER_OR_EQUAL_THAN: cr.add(Restrictions.ge(line.getFieldName(), line.getValue())); break; case GREATER_THAN: cr.add(Restrictions.gt(line.getFieldName(), line.getValue())); break; case ICONTAINS: cr.add(Restrictions.ilike(line.getFieldName(), "%" + line.getValue() + "%")); break; case LESS_OR_EQUAL_THAN: cr.add(Restrictions.le(line.getFieldName(), line.getValue())); break; case LESS_THAN: cr.add(Restrictions.lt(line.getFieldName(), line.getValue())); break; case NOT_EQUALS: cr.add(Restrictions.ne(line.getFieldName(), line.getValue())); break; case ISNULL: cr.add(Restrictions.isNull(line.getFieldName())); break; case NOTNULL: cr.add(Restrictions.isNotNull(line.getFieldName())); break; default: break; } } for (SortLine sort : filter.getSortLines()) { if (sort.isAscending()) cr.addOrder(Property.forName(sort.getField()).asc()); else cr.addOrder(Property.forName(sort.getField()).desc()); } if (filter.getLimit() != 0) cr.setMaxResults(filter.getLimit()); if (filter.getOffset() != 0) cr.setFirstResult(filter.getOffset()); return cr; }
From source file:org.hoteia.qalingo.core.dao.ProductDao.java
License:Apache License
public List<ProductMarketing> findProductMarketingsNotInThisMasterCatalogCategoryId(final Long categoryId, Object... params) {/*from www.ja v a 2s. com*/ Criteria criteria = createDefaultCriteria(ProductMarketing.class); handleSpecificProductMarketingFetchMode(criteria, params); criteria.createAlias("productSkus", "productSku", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("productSku.catalogCategoryMasterProductSkuRels", "catalogCategoryProductSkuRel", JoinType.LEFT_OUTER_JOIN); criteria.add(Restrictions.ne("catalogCategoryProductSkuRel.pk.catalogCategoryMaster.id", categoryId)); criteria.addOrder(Order.asc("id")); @SuppressWarnings("unchecked") List<ProductMarketing> productMarketings = criteria.list(); return productMarketings; }