Example usage for org.hibernate.criterion Restrictions leProperty

List of usage examples for org.hibernate.criterion Restrictions leProperty

Introduction

In this page you can find the example usage for org.hibernate.criterion Restrictions leProperty.

Prototype

public static PropertyExpression leProperty(String propertyName, String otherPropertyName) 

Source Link

Document

Apply a "less than or equal" constraint to two properties

Usage

From source file:ar.com.zauber.commons.repository.query.visitor.CriteriaFilterVisitor.java

License:Apache License

/** calculate a criterion */
private Criterion createPropertyCriterion(final BinaryPropertyFilter binaryPropertyFilter,
        final String otherProperty) {
    final String fieldName = getFieldName(binaryPropertyFilter.getProperty());
    final Criterion ret;

    if (binaryPropertyFilter instanceof EqualsPropertyFilter) {
        ret = Restrictions.eqProperty(fieldName, otherProperty);
    } else if (binaryPropertyFilter instanceof LessThanPropertyFilter) {
        ret = Restrictions.ltProperty(fieldName, otherProperty);
    } else if (binaryPropertyFilter instanceof LessThanEqualsPropertyFilter) {
        ret = Restrictions.leProperty(fieldName, otherProperty);
    } else if (binaryPropertyFilter instanceof GreaterThanPropertyFilter) {
        ret = Restrictions.gtProperty(fieldName, otherProperty);
    } else if (binaryPropertyFilter instanceof GreaterThanEqualsPropertyFilter) {
        ret = Restrictions.geProperty(fieldName, otherProperty);
    } else {//  ww w  .j  av a2 s  .  co m
        throw new IllegalStateException("Unable to process filter" + binaryPropertyFilter);
    }

    return ret;
}

From source file:com.heliosapm.aa4h.parser.XMLQueryParser.java

License:Apache License

/**
 * Element Start SAX ContentHandler Method.
 * @param uri//  www . j av a2s .c  om
 * @param localName
 * @param qName
 * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
 * @throws SAXException
 * TODO: Document supported tags in javadoc.
 */
@SuppressWarnings({ "unchecked" })
public void startElement(String uri, String localNameX, String qName, Attributes attrs) throws SAXException {
    if ("Query".equalsIgnoreCase(qName)) {
        queryName = attrs.getValue("name");
        rootElementName = queryName;
    } else if ("Class".equalsIgnoreCase(qName)) {
        processCriteria(attrs);
    } else if ("Union".equalsIgnoreCase(qName)) {
        inDetached = true;
        DetachedCriteria dc = DetachedCriteria.forEntityName(className);
        criteriaStack.push(dc);
    } else if ("NamedQuery".equalsIgnoreCase(qName)) {
        isNamedQuery = true;
        namedQuery = attrs.getValue("name");
        rootElementName = namedQuery;
        try {
            query = session.getNamedQuery(namedQuery);
        } catch (HibernateException he) {
            throw new SAXException("Failed to retrieve named query[" + namedQuery + "]", he);
        }
    } else if ("qparam".equalsIgnoreCase(qName)) {
        processQueryBind(attrs);
    } else if ("Join".equalsIgnoreCase(qName)) {
        processCriteria(attrs);
    } else if ("Projections".equalsIgnoreCase(qName)) {
        startProjection(attrs);
    } else if ("Projection".equalsIgnoreCase(qName)) {
        addProjection(attrs);
    } else if ("Order".equalsIgnoreCase(qName)) {
        if (isRowCountOnly() == false) {
            try {
                String name = attrs.getValue("name");
                String type = attrs.getValue("type");
                ((Criteria) criteriaStack.peek())
                        .addOrder(type.equalsIgnoreCase("asc") ? Order.asc(name) : Order.desc(name));
            } catch (Exception e) {
                throw new SAXException("Unable To Parse GreaterThan:" + attrs.getValue("name"), e);
            }
        }
    } else if ("GreaterThan".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            addCriterion(Restrictions.gt(operator.getName(), operator.getNativeValue()));
        } catch (Exception e) {
            throw new SAXException("Unable To Parse GreaterThan:" + attrs.getValue("name"), e);
        }
    } else if ("GreaterThanOrEqual".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            addCriterion(Restrictions.ge(operator.getName(), operator.getNativeValue()));
        } catch (Exception e) {
            throw new SAXException("Unable To Parse GreaterThanOrEqual:" + attrs.getValue("name"), e);
        }
    } else if ("LessThan".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            addCriterion(Restrictions.lt(operator.getName(), operator.getNativeValue()));
        } catch (Exception e) {
            throw new SAXException("Unable To Parse LessThan:" + attrs.getValue("name"), e);
        }
    } else if ("LessThanOrEqual".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            addCriterion(Restrictions.le(operator.getName(), operator.getNativeValue()));
        } catch (Exception e) {
            throw new SAXException("Unable To Parse LessThanOrEqual:" + attrs.getValue("name"), e);
        }
    } else if ("Equals".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            if ("true".equalsIgnoreCase(attrs.getValue("not"))) {
                addCriterion(Restrictions.not(Restrictions.eq(operator.getName(), operator.getNativeValue())));
            } else {
                addCriterion(Restrictions.eq(operator.getName(), operator.getNativeValue()));
            }

        } catch (Exception e) {
            throw new SAXException("Unable To Parse Equals:" + attrs.getValue("name"), e);
        }
    } else if ("Alias".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            ((Criteria) criteriaStack.peek()).createAlias(operator.getName(), operator.getValue());
        } catch (Exception e) {
            throw new SAXException("Unable To Create Alias:" + attrs.getValue("name"), e);
        }
    } else if ("GreaterThanProperty".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            addCriterion(Restrictions.gtProperty(operator.getName(), operator.getName2()));
        } catch (Exception e) {
            throw new SAXException("Unable To Parse GreaterThanProperty:" + attrs.getValue("name"), e);
        }
    } else if ("GreaterThanOrEqualProperty".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            addCriterion(Restrictions.geProperty(operator.getName(), operator.getName2()));
        } catch (Exception e) {
            throw new SAXException("Unable To Parse GreaterThanOrEqualProperty:" + attrs.getValue("name"), e);
        }
    } else if ("LessThanProperty".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            addCriterion(Restrictions.ltProperty(operator.getName(), operator.getName2()));
        } catch (Exception e) {
            throw new SAXException("Unable To Parse LessThanProperty:" + attrs.getValue("name"), e);
        }
    } else if ("LessThanOrEqualProperty".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            addCriterion(Restrictions.leProperty(operator.getName(), operator.getName2()));
        } catch (Exception e) {
            throw new SAXException("Unable To Parse LessThanOrEqualProperty:" + attrs.getValue("name"), e);
        }
    } else if ("EqualsProperty".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            if ("true".equalsIgnoreCase(attrs.getValue("not"))) {
                addCriterion(
                        Restrictions.not(Restrictions.eqProperty(operator.getName(), operator.getName2())));
            } else {
                addCriterion(Restrictions.eqProperty(operator.getName(), operator.getName2()));
            }
        } catch (Exception e) {
            throw new SAXException("Unable To Parse EqualsProperty:" + attrs.getValue("name"), e);
        }
    } else if ("Like".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            addCriterion(Restrictions.like(operator.getName(), operator.getNativeValue()));
        } catch (Exception e) {
            throw new SAXException("Unable To Parse Like:" + attrs.getValue("name"), e);
        }
    } else if ("Between".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            addCriterion(Restrictions.between(operator.getName(), operator.getNativeValue(),
                    operator.getNativeValue2()));
        } catch (Exception e) {
            throw new SAXException("Unable To Parse Between:" + attrs.getValue("name"), e);
        }
    } else if ("IsEmpty".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            addCriterion(Restrictions.isEmpty(operator.getName()));
        } catch (Exception e) {
            throw new SAXException("Unable To Parse IsEmpty:" + attrs.getValue("name"), e);
        }
    } else if ("IsNotEmpty".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            addCriterion(Restrictions.isNotEmpty(operator.getName()));
        } catch (Exception e) {
            throw new SAXException("Unable To Parse IsNotEmpty:" + attrs.getValue("name"), e);
        }
    } else if ("IsNull".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            addCriterion(Restrictions.isNull(operator.getName()));
        } catch (Exception e) {
            throw new SAXException("Unable To Parse IsNull:" + attrs.getValue("name"), e);
        }
    } else if ("IsNotNull".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            addCriterion(Restrictions.isNotNull(operator.getName()));
        } catch (Exception e) {
            throw new SAXException("Unable To Parse IsNotNull:" + attrs.getValue("name"), e);
        }
    } else if ("In".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            if (operator.isLiteral()) {
                addCriterion(new LiteralInExpression(operator.getName(), (String) operator.getNativeValue()));
            } else {
                addCriterion(Restrictions.in(operator.getName(), (Collection) operator.getNativeValue()));
            }
        } catch (Exception e) {
            throw new SAXException("Unable To Parse In:" + attrs.getValue("name"), e);
        }
    } else if ("SizeEquals".equalsIgnoreCase(qName)) {
        try {
            Operator operator = new Operator(attrs);
            int i = ((Integer) operator.getNativeValue()).intValue();
            addCriterion(Restrictions.sizeEq(operator.getName(), i));
        } catch (Exception e) {
            throw new SAXException("Unable To Parse SizeEquals:" + attrs.getValue("name"), e);
        }
    } else if ("Not".equalsIgnoreCase(qName)) {
        notStack.push(new Object());
    } else if ("Or".equalsIgnoreCase(qName)) {
        opStack.push(Restrictions.disjunction());
    } else if ("And".equalsIgnoreCase(qName)) {
        opStack.push(Restrictions.conjunction());
    } else {
        throw new SAXException("Element Name[" + qName + "] Not Recognized.");
    }
}

From source file:com.qcadoo.model.api.search.SearchRestrictions.java

License:Open Source License

/**
 * Creates criterion which checks if field is less than or equal to other field.
 * /* w w  w  .j a va  2s  .c o m*/
 * @param field
 *            field
 * @param otherField
 *            other field
 * @return criterion
 */
public static SearchCriterion leField(final String field, final String otherField) {
    return new SearchCriterionImpl(Restrictions.leProperty(field, otherField));
}

From source file:edu.utah.further.core.data.hibernate.query.CriterionBuilderHibernateImpl.java

License:Apache License

/**
 * @param <E>/*from w w w. j a va 2s .  c o  m*/
 * @param criterion
 * @see #visit(edu.utah.further.core.search.PropertyExpression)
 */
public <E> void visitPropertyExpression() {
    final Relation relation = (Relation) criterion.getParameter(0);
    final String propertyName = (String) criterion.getParameter(1);
    final String otherPropertyName = (String) criterion.getParameter(2);
    switch (relation) {
    case EQ: {
        result = eqProperty(propertyName, otherPropertyName);
        break;
    }

    case NE: {
        result = neProperty(propertyName, otherPropertyName);
        break;
    }

    case GT: {
        result = gtProperty(propertyName, otherPropertyName);
        break;
    }

    case GE: {
        result = geProperty(propertyName, otherPropertyName);
        break;
    }

    case LT: {
        result = Restrictions.ltProperty(propertyName, otherPropertyName);
        break;
    }

    case LE: {
        result = Restrictions.leProperty(propertyName, otherPropertyName);
        break;
    }

    default: {
        throw new BusinessRuleException(unsupportedMessage(relation));
    }
    }
}

From source file:fr.gael.dhus.olingo.v1.SQLVisitor.java

License:Open Source License

private Criterion getCriterionComparative(BinaryOperator operator, Object left, Object right) {
    Criterion criterion = null;/* ww  w.j  av a2 s  . co  m*/
    if (left instanceof Member) {
        if (right instanceof Member) {
            // property <operator> property
            String lvalue = ((Member) left).getName();
            String rvalue = ((Member) right).getName();
            switch (operator) {
            case EQ: {
                criterion = Restrictions.eqProperty(lvalue, rvalue);
                break;
            }
            case NE: {
                criterion = Restrictions.neProperty(lvalue, rvalue);
                break;
            }
            case GT: {
                criterion = Restrictions.gtProperty(lvalue, rvalue);
                break;
            }
            case GE: {
                criterion = Restrictions.geProperty(lvalue, rvalue);
                break;
            }
            case LT: {
                criterion = Restrictions.ltProperty(lvalue, rvalue);
                break;
            }
            case LE: {
                criterion = Restrictions.leProperty(lvalue, rvalue);
                break;
            }
            default:
                throw new UnsupportedOperationException("Unsupported operation: " + operator.toUriLiteral());
            }
        } else {
            // property <operator> literal
            String property = ((Member) left).getName();
            criterion = internalCriterionComparative(operator, property, right);
        }
    } else if (right instanceof Member) {
        // literal <operator> property
        String property = ((Member) right).getName();
        criterion = internalCriterionComparative(operator, property, left);
    } else if (left instanceof Comparable) {
        // literal <operator> literal
        Comparable comparable = (Comparable) left;
        boolean bool;
        int result = comparable.compareTo(right);
        switch (operator) {
        case EQ: {
            bool = result == 0;
            break;
        }
        case NE: {
            bool = result != 0;
            break;
        }
        case GT: {
            bool = result > 0;
            break;
        }
        case GE: {
            bool = result >= 0;
            break;
        }
        case LT: {
            bool = result < 0;
            break;
        }
        case LE: {
            bool = result <= 0;
            break;
        }
        default:
            throw new UnsupportedOperationException("Unsupported operation: " + operator.toUriLiteral());
        }
        if (bool) {
            criterion = Restrictions.sqlRestriction("0=0");
        } else {
            criterion = Restrictions.sqlRestriction("0<>0");
        }
    }
    return criterion;
}

From source file:grails.orm.HibernateCriteriaBuilder.java

License:Apache License

/**
 * Creates a Criterion that tests if the first property is less than or equal to the second property
 * @param propertyName The first property name
 * @param otherPropertyName The second property name
 * @return A Criterion instance/*from   w  w w. j a  va2s. com*/
 */
public org.grails.datastore.mapping.query.api.Criteria leProperty(String propertyName,
        String otherPropertyName) {
    if (!validateSimpleExpression()) {
        throwRuntimeException(new IllegalArgumentException("Call to [leProperty] with propertyName ["
                + propertyName + "] and other property name [" + otherPropertyName + "] not allowed here."));
    }

    propertyName = calculatePropertyName(propertyName);
    otherPropertyName = calculatePropertyName(otherPropertyName);
    addToCriteria(Restrictions.leProperty(propertyName, otherPropertyName));
    return this;
}

From source file:org.balisunrise.daa.hibernate.HCriteria.java

License:Open Source License

private org.hibernate.criterion.Criterion makeCriterion(Criterion.Comparator comparator) {

    String fp = aliasMap.getPropertyName(comparator.getFirstProperty());
    String sp = aliasMap.getPropertyName(comparator.getSecondProperty());

    switch (comparator.getComparatorType()) {
    case EQUALS://  w  w  w.ja  va  2s  .c o m
        return Restrictions.eqProperty(fp, sp);
    case DIFFERENT:
        return Restrictions.neProperty(fp, sp);
    case GREATHER:
        return Restrictions.gtProperty(fp, sp);
    case GREATHER_EQUALS:
        return Restrictions.geProperty(fp, sp);
    case LESS:
        return Restrictions.ltProperty(fp, sp);
    case LESS_EQUALS:
        return Restrictions.leProperty(fp, sp);
    }
    return null;
}

From source file:org.codehaus.groovy.grails.orm.hibernate.query.AbstractHibernateCriterionAdapter.java

License:Apache License

protected void addPropertyComparisonCriterionAdapters() {
    criterionAdaptors.put(Query.EqualsProperty.class, new CriterionAdaptor<Query.EqualsProperty>() {
        @Override/*from  ww w .j  a v  a2  s .  c o m*/
        public Criterion toHibernateCriterion(AbstractHibernateQuery hibernateQuery,
                Query.EqualsProperty criterion, String alias) {
            String propertyName = getPropertyName(criterion, alias);
            return Restrictions.eqProperty(propertyName, criterion.getOtherProperty());
        }
    });
    criterionAdaptors.put(Query.GreaterThanProperty.class, new CriterionAdaptor<Query.GreaterThanProperty>() {
        @Override
        public Criterion toHibernateCriterion(AbstractHibernateQuery hibernateQuery,
                Query.GreaterThanProperty criterion, String alias) {
            String propertyName = getPropertyName(criterion, alias);
            return Restrictions.gtProperty(propertyName, criterion.getOtherProperty());
        }
    });
    criterionAdaptors.put(Query.GreaterThanEqualsProperty.class,
            new CriterionAdaptor<Query.GreaterThanEqualsProperty>() {
                @Override
                public Criterion toHibernateCriterion(AbstractHibernateQuery hibernateQuery,
                        Query.GreaterThanEqualsProperty criterion, String alias) {
                    String propertyName = getPropertyName(criterion, alias);
                    return Restrictions.geProperty(propertyName, criterion.getOtherProperty());
                }
            });
    criterionAdaptors.put(Query.LessThanProperty.class, new CriterionAdaptor<Query.LessThanProperty>() {
        @Override
        public Criterion toHibernateCriterion(AbstractHibernateQuery hibernateQuery,
                Query.LessThanProperty criterion, String alias) {
            String propertyName = getPropertyName(criterion, alias);
            return Restrictions.ltProperty(propertyName, criterion.getOtherProperty());
        }
    });
    criterionAdaptors.put(Query.LessThanEqualsProperty.class,
            new CriterionAdaptor<Query.LessThanEqualsProperty>() {
                @Override
                public Criterion toHibernateCriterion(AbstractHibernateQuery hibernateQuery,
                        Query.LessThanEqualsProperty criterion, String alias) {
                    String propertyName = getPropertyName(criterion, alias);
                    return Restrictions.leProperty(propertyName, criterion.getOtherProperty());
                }
            });
    criterionAdaptors.put(Query.NotEqualsProperty.class, new CriterionAdaptor<Query.NotEqualsProperty>() {
        @Override
        public Criterion toHibernateCriterion(AbstractHibernateQuery hibernateQuery,
                Query.NotEqualsProperty criterion, String alias) {
            String propertyName = getPropertyName(criterion, alias);
            return Restrictions.neProperty(propertyName, criterion.getOtherProperty());
        }
    });
}

From source file:org.sculptor.framework.accessimpl.jpahibernate.JpaHibFindByConditionAccessImpl.java

License:Apache License

private Criterion makeCriterion(ConditionalCriteria crit) {
    if (crit == null) {
        return null;
    }//from   w w w  .  j a v  a  2  s  . com

    ConditionalCriteria.Operator operator = crit.getOperator();
    if (Operator.Equal.equals(operator)) {
        return Restrictions.eq(makePathWithAlias(crit.getPropertyFullName()), crit.getFirstOperant());
    } else if (Operator.IgnoreCaseEqual.equals(operator)) {
        return Restrictions.eq(makePathWithAlias(crit.getPropertyFullName()), crit.getFirstOperant())
                .ignoreCase();
    } else if (Operator.LessThan.equals(operator)) {
        return Restrictions.lt(makePathWithAlias(crit.getPropertyFullName()), crit.getFirstOperant());
    } else if (Operator.LessThanOrEqual.equals(operator)) {
        return Restrictions.le(makePathWithAlias(crit.getPropertyFullName()), crit.getFirstOperant());
    } else if (Operator.GreatThan.equals(operator)) {
        return Restrictions.gt(makePathWithAlias(crit.getPropertyFullName()), crit.getFirstOperant());
    } else if (Operator.GreatThanOrEqual.equals(operator)) {
        return Restrictions.ge(makePathWithAlias(crit.getPropertyFullName()), crit.getFirstOperant());
    } else if (Operator.Like.equals(operator)) {
        // Hibernate bug HHH-5339 + PostgreSQL missing 'number like string' conversion
        return new NumericLikeExpression(makePathWithAlias(crit.getPropertyFullName()),
                crit.getFirstOperant().toString(), false);
    } else if (Operator.IgnoreCaseLike.equals(operator)) {
        // Hibernate bug HHH-5339 + PostgreSQL missing 'number like string' conversion
        return new NumericLikeExpression(makePathWithAlias(crit.getPropertyFullName()),
                crit.getFirstOperant().toString(), true);
    } else if (Operator.IsNull.equals(operator)) {
        return Restrictions.isNull(makePathWithAlias(crit.getPropertyFullName()));
    } else if (Operator.IsNotNull.equals(operator)) {
        return Restrictions.isNotNull(makePathWithAlias(crit.getPropertyFullName()));
    } else if (Operator.IsEmpty.equals(operator)) {
        return Restrictions.isEmpty(makePathWithAlias(crit.getPropertyFullName()));
    } else if (Operator.IsNotEmpty.equals(operator)) {
        return Restrictions.isNotEmpty(makePathWithAlias(crit.getPropertyFullName()));
    } else if (Operator.Not.equals(operator)) {
        return Restrictions.not(makeCriterion((ConditionalCriteria) crit.getFirstOperant()));
    } else if (Operator.Or.equals(operator) && crit.getFirstOperant() instanceof List<?>) {
        Disjunction disj = Restrictions.disjunction();
        List<?> disjList = (List<?>) crit.getFirstOperant();
        for (Object disjPart : disjList) {
            disj.add(makeCriterion((ConditionalCriteria) disjPart));
        }
        return disj;
    } else if (Operator.Or.equals(operator)) {
        return Restrictions.or(makeCriterion((ConditionalCriteria) crit.getFirstOperant()),
                makeCriterion((ConditionalCriteria) crit.getSecondOperant()));
    } else if (Operator.And.equals(operator) && crit.getFirstOperant() instanceof List<?>) {
        Conjunction conj = Restrictions.conjunction();
        List<?> conjList = (List<?>) crit.getFirstOperant();
        for (Object conjPart : conjList) {
            conj.add(makeCriterion((ConditionalCriteria) conjPart));
        }
        return conj;
    } else if (Operator.And.equals(operator)) {
        return Restrictions.and(makeCriterion((ConditionalCriteria) crit.getFirstOperant()),
                makeCriterion((ConditionalCriteria) crit.getSecondOperant()));
    } else if (Operator.In.equals(operator)) {
        if (crit.getFirstOperant() instanceof Collection<?>) {
            return Restrictions.in(makePathWithAlias(crit.getPropertyFullName()),
                    (Collection<?>) crit.getFirstOperant());
        } else {
            return Restrictions.in(makePathWithAlias(crit.getPropertyFullName()),
                    (Object[]) crit.getFirstOperant());
        }
    } else if (Operator.Between.equals(operator)) {
        return Restrictions.between(makePathWithAlias(crit.getPropertyFullName()), crit.getFirstOperant(),
                crit.getSecondOperant());
    } else if (Operator.DistinctRoot.equals(operator)) {
        realDistinctRoot = true;
        return null;
    } else if (Operator.ProjectionRoot.equals(operator)) {
        resultTransformer = Criteria.PROJECTION;
        return null;
    } else if (Operator.EqualProperty.equals(operator)) {
        return Restrictions.eqProperty(makePathWithAlias(crit.getPropertyFullName()),
                (String) crit.getFirstOperant());
    } else if (Operator.LessThanProperty.equals(operator)) {
        return Restrictions.ltProperty(makePathWithAlias(crit.getPropertyFullName()),
                (String) crit.getFirstOperant());
    } else if (Operator.LessThanOrEqualProperty.equals(operator)) {
        return Restrictions.leProperty(makePathWithAlias(crit.getPropertyFullName()),
                (String) crit.getFirstOperant());
    } else if (Operator.GreatThanProperty.equals(operator)) {
        return Restrictions.gtProperty(makePathWithAlias(crit.getPropertyFullName()),
                (String) crit.getFirstOperant());
    } else if (Operator.GreatThanOrEqualProperty.equals(operator)) {
        return Restrictions.geProperty(makePathWithAlias(crit.getPropertyFullName()),
                (String) crit.getFirstOperant());
    } else {
        return null;
    }
}

From source file:to.etc.domui.hibernate.model.CriteriaCreatingVisitor.java

License:Open Source License

@Override
public void visitPropertyJoinComparison(@NonNull QPropertyJoinComparison comparison) throws Exception {
    String alias = m_parentAlias + "." + parseSubcriteria(comparison.getParentProperty());
    switch (comparison.getOperation()) {
    default:/*from w w  w .j a  v a2  s .  com*/
        throw new QQuerySyntaxException("Unsupported parent-join operation: " + comparison.getOperation());

    case EQ:
        m_last = Restrictions.eqProperty(alias, comparison.getSubProperty());
        break;

    case NE:
        m_last = Restrictions.neProperty(alias, comparison.getSubProperty());
        break;

    case LT:
        m_last = Restrictions.ltProperty(alias, comparison.getSubProperty());
        break;

    case LE:
        m_last = Restrictions.leProperty(alias, comparison.getSubProperty());
        break;

    case GT:
        m_last = Restrictions.gtProperty(alias, comparison.getSubProperty());
        break;

    case GE:
        m_last = Restrictions.geProperty(alias, comparison.getSubProperty());
        break;
    }
}