Examples of like()


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

      criteriaQuery.from(c);   

    criteriaQuery
      .select(root)
      .where(
        criteriaBuilder.like(
          root.get("nome").as(String.class),
          nome + "%" 
        )
      );
       
View Full Code Here

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

        CriteriaQuery<Movie> query = builder.createQuery(Movie.class);
        Root<Movie> root = query.from(Movie.class);
        EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);

        Path<String> path = root.get(type.getDeclaredSingularAttribute(fieldname, String.class));
        Predicate condition = builder.like(path, "%" + param + "%");

        query.where(condition);

        return entityManager.createQuery(query).getResultList();
    }
View Full Code Here

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

            Path<?> path = from.get(attribute);
            Class<?> javaType = attribute.getType().getJavaType();

            Predicate currentClause;
            if (javaType.equals(String.class)) {
                currentClause = cb.like((Expression<String>) path, (String) args[i++]);
            } else if (Number.class.isAssignableFrom(javaType) || javaType.isPrimitive()) {
                currentClause = cb.equal(path, args[i++]);
            } else {
                LOGGER.warning("field " + condition + " not found, ignoring");
                continue;
View Full Code Here

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

        q.select(book);
       
        // Builds the predicates conditionally for the filled-in input fields
        List<Predicate> predicates = new ArrayList<Predicate>();
        if (!isEmpty(title)) {
            Predicate matchTitle = cb.like(book.get(Book_.title), title);
            predicates.add(matchTitle);
        }
        if (!isEmpty(author)) {
            Predicate matchAuthor = cb.like(book.join(Book_.authors).get(Author_.name), "%"+author+"%");
            predicates.add(matchAuthor);
View Full Code Here

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

        if (!isEmpty(title)) {
            Predicate matchTitle = cb.like(book.get(Book_.title), title);
            predicates.add(matchTitle);
        }
        if (!isEmpty(author)) {
            Predicate matchAuthor = cb.like(book.join(Book_.authors).get(Author_.name), "%"+author+"%");
            predicates.add(matchAuthor);
        }
        // for price fields, also the comparison operation changes based on whether
        // minimum or maximum price or both have been filled.
        if (minPrice != null && maxPrice != null) {
View Full Code Here

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

    criteria.select( orderRoot );
    // create correlated subquery
    Subquery<Customer> customerSubquery = criteria.subquery( Customer.class );
    Root<Order> orderRootCorrelation = customerSubquery.correlate( orderRoot );
    Join<Order, Customer> orderCustomerJoin = orderRootCorrelation.join( Order_.customer );
    customerSubquery.where( builder.like( orderCustomerJoin.get( Customer_.name ), "%Caruso" ) )
        .select( orderCustomerJoin );
    criteria.where( builder.exists( customerSubquery ) );
    em.createQuery( criteria ).getResultList();

    em.getTransaction().commit();
View Full Code Here

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

    criteria.select( orderRoot );
    // create correlated subquery
    Subquery<Customer> customerSubquery = criteria.subquery( Customer.class );
    Root<Order> orderRootCorrelation = customerSubquery.correlate( orderRoot );
    Join<Order, Customer> orderCustomerJoin = orderRootCorrelation.join( "customer" );
    customerSubquery.where( builder.like( orderCustomerJoin.<String>get( "name" ), "%Caruso" ) );
    criteria.where( builder.exists( customerSubquery ) );
    em.createQuery( criteria ).getResultList();

    em.getTransaction().commit();
    em.close();
View Full Code Here

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

            Path<?> path = from.get(attribute);
            Class<?> javaType = attribute.getType().getJavaType();

            Predicate currentClause;
            if (javaType.equals(String.class)) {
                currentClause = cb.like((Expression<String>) path, (String) args[i++]);
            } else if (Number.class.isAssignableFrom(javaType) || javaType.isPrimitive()) {
                currentClause = cb.equal(path, args[i++]);
            } else {
                LOGGER.warning("field " + condition + " not found, ignoring");
                continue;
View Full Code Here

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

        if(createdDateBegin != null && createdDateEnd != null) {
            where = cb.and(where, cb.between(z.get(Request_.createdDate), createdDateBegin, createdDateEnd));
        }
       
        if(description != null) {
            where = cb.and(where, cb.like(z.get(Request_.description), "%" + description + "%"));
        }
       
        if(text != null) {
            where = cb.and(where, cb.like(z.get(Request_.text), "%" + text + "%"));
        }
View Full Code Here

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

        if(description != null) {
            where = cb.and(where, cb.like(z.get(Request_.description), "%" + description + "%"));
        }
       
        if(text != null) {
            where = cb.and(where, cb.like(z.get(Request_.text), "%" + text + "%"));
        }
       
        if(serviceObject != null) {
            where = cb.and(where, cb.equal(z.get(Request_.serviceObject), serviceObject));
        }
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.