Package javax.persistence.criteria

Examples of javax.persistence.criteria.CriteriaBuilder.gt()


    Root<Customer> customer = customerCriteria.from( Customer.class );
    Join<Customer, Order> o = customer.join( Customer_.orders );
    Subquery<Order> sq = customerCriteria.subquery(Order.class);
    Join<Customer, Order> sqo = sq.correlate(o);
    Join<Order, LineItem> sql = sqo.join(Order_.lineItems);
    sq.where( builder.gt(sql.get( LineItem_.quantity), 3) );
    // use the correlation itself as the subquery selection (initially caused problems wrt aliases)
    sq.select(sqo);
    customerCriteria.select(customer).distinct(true);
    customerCriteria.where(builder.exists(sq));
    em.createQuery( customerCriteria ).getResultList();
View Full Code Here


            Subquery<JPAObject> sub = query.subquery(JPAObject.class);
            Root f = sub.from(JPAObject.class);
            sub.select(f);
            Predicate subPredicate1 = criteriaBuilder.equal(from.get("oid"), f.get("oid"));
            Predicate subPredicate2 = criteriaBuilder.equal(f.get("isDeleted"), Boolean.TRUE);
            Predicate subPredicate3 = criteriaBuilder.gt(from.get("timestamp"), f.get("timestamp"));
            sub.where(criteriaBuilder.and(subPredicate1, subPredicate2, subPredicate3));

            Predicate predicate1 = criteriaBuilder.notEqual(from.get("isDeleted"), Boolean.TRUE);
            Predicate predicate2 = criteriaBuilder.exists(sub);
            query.where(predicate1, predicate2);
View Full Code Here

        CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
        CriteriaQuery<E> query = criteriaBuilder.createQuery(clazz);
        Root<E> from = query.from(clazz);
        query.select(from.alias("p"));
        query.where(criteriaBuilder.and(criteriaBuilder.equal(from.get(fieldName), name),
                criteriaBuilder.gt((Expression) from.get("age"), Integer.parseInt(minVal))));

        TypedQuery<E> q = em.createQuery(query);
        List<E> results = q.getResultList();
        Assert.assertNotNull(results);
        Assert.assertFalse(results.isEmpty());
View Full Code Here

        CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
        CriteriaQuery<E> query = criteriaBuilder.createQuery(clazz);
        Root<E> from = query.from(clazz);
        query.select(from.alias("p"));
        query.where(criteriaBuilder.and(criteriaBuilder.equal(from.get(fieldName), name),
                criteriaBuilder.gt((Expression) from.get("age"), Integer.parseInt(minVal)),
                criteriaBuilder.lt((Expression) from.get("age"), Integer.parseInt(maxVal))));

        // // // find by name, age clause
        TypedQuery<E> q = em.createQuery(query);
        List<E> results = q.getResultList();
View Full Code Here

        CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
        CriteriaQuery<Person> personQuery = criteriaBuilder.createQuery(Person.class);
        Root<Person> from = personQuery.from(Person.class);
        personQuery.select(from.alias("p"));
        personQuery.where(criteriaBuilder.and(criteriaBuilder.equal(from.get("personName"), "vivek"),
                criteriaBuilder.gt((Expression) from.get("age"), new Integer(32))));
        String actual = CriteriaQueryTranslator.translate(personQuery);
        Assert.assertEquals(expected.trim(), actual.trim());
    }

    @Test
View Full Code Here

        CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
        CriteriaQuery<Person> personQuery = criteriaBuilder.createQuery(Person.class);
        Root<Person> from = personQuery.from(Person.class);
        personQuery.select(from.alias("p"));
        personQuery.where(criteriaBuilder.and(criteriaBuilder.equal(from.get("personName"), "vivek"),
                criteriaBuilder.gt((Expression)from.get("age"), 32),criteriaBuilder.le((Expression)from.get("salary"), 3200.01)));
        String actual = CriteriaQueryTranslator.translate(personQuery);
        Assert.assertEquals(expected.trim(), actual.trim());
    }

    @Test
View Full Code Here

        CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
        CriteriaQuery<Person> personQuery = criteriaBuilder.createQuery(Person.class);
        Root<Person> from = personQuery.from(Person.class);
        personQuery.select(from.alias("p"));
        personQuery.where(criteriaBuilder.and(criteriaBuilder.equal(from.get("personName"), "vivek"),
                criteriaBuilder.gt((Expression)from.get("age"), 32),criteriaBuilder.le((Expression)from.get("salary"), 3200.01)));
        personQuery.orderBy(criteriaBuilder.desc(from.get("personName")));
        String actual = CriteriaQueryTranslator.translate(personQuery);
        Assert.assertEquals(expected.trim(), actual.trim());
    }
View Full Code Here

          } else if (t == Filter.LESS_THAN) {
            predicates.add(builder.lt(numPath, numVal));
          } else if (t == Filter.LESS_THAN_EQUAL) {
            predicates.add(builder.le(numPath, numVal));
          } else if (t == Filter.GREATER_THAN) {
            predicates.add(builder.gt(numPath, numVal));
          } else if (t == Filter.GREATER_THAN_EQUAL) {
            predicates.add(builder.ge(numPath, numVal));
          }
         
        /*
 
View Full Code Here

          } else if (t == Filter.LESS_THAN) {
            predicates.add(builder.lt(numPath, numVal));
          } else if (t == Filter.LESS_THAN_EQUAL) {
            predicates.add(builder.le(numPath, numVal));
          } else if (t == Filter.GREATER_THAN) {
            predicates.add(builder.gt(numPath, numVal));
          } else if (t == Filter.GREATER_THAN_EQUAL) {
            predicates.add(builder.ge(numPath, numVal));
          }
         
        /*
 
View Full Code Here

        {
          predicate = cb.notEqual(propertyExpression, value);
        }
        else if (PersistenceCriterion.OPERATOR_GT.equals(operator))
        {
          predicate = cb.gt(propertyExpression, obtainNumber(value, beanClass, property));
        }
        else if (PersistenceCriterion.OPERATOR_GTE.equals(operator))
        {
          predicate = cb.ge(propertyExpression, obtainNumber(value, beanClass, property));
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.