Example usage for javax.persistence.criteria CriteriaBuilder like

List of usage examples for javax.persistence.criteria CriteriaBuilder like

Introduction

In this page you can find the example usage for javax.persistence.criteria CriteriaBuilder like.

Prototype

Predicate like(Expression<String> x, String pattern);

Source Link

Document

Create a predicate for testing whether the expression satisfies the given pattern.

Usage

From source file:edu.pitt.dbmi.ccd.db.specification.GroupSpecification.java

private static Predicate descriptionContains(Root<Group> root, CriteriaBuilder cb, String term) {
    return cb.like(cb.lower(root.get(DESC)), term);
}

From source file:edu.pitt.dbmi.ccd.db.specification.VocabularySpecification.java

private static Predicate nameContains(Root<Vocabulary> root, CriteriaBuilder cb, String term) {
    return cb.like(cb.lower(root.get(NAME)), term);
}

From source file:edu.pitt.dbmi.ccd.db.specification.VocabularySpecification.java

private static Predicate descriptionContains(Root<Vocabulary> root, CriteriaBuilder cb, String term) {
    return cb.like(cb.lower(root.get(DESC)), term);
}

From source file:th.co.geniustree.dental.spec.AppointmentSpec.java

public static Specification<Appointment> nameDoctorLike(final String keyword) {
    return new Specification<Appointment>() {

        @Override/*from  ww w  .j a  v  a 2s  .  c om*/
        public Predicate toPredicate(Root<Appointment> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
            return cb.or(
                    cb.like(cb.upper(root.get(Appointment_.doctor).get(Doctor_.nameEng)),
                            keyword.toUpperCase()),
                    cb.like(root.get(Appointment_.doctor).get(Doctor_.nameTh), keyword));
        }
    };
}

From source file:th.co.geniustree.dental.spec.EmployeeSpec.java

public static Specification<Employee> emailLike(final String keyword) {
    return new Specification<Employee>() {

        @Override/*  w w w  . j  av  a 2  s.c o m*/
        public Predicate toPredicate(Root<Employee> root, CriteriaQuery<?> cq, CriteriaBuilder cb) {
            CriteriaQuery cc = cq.orderBy(cb.desc(root.get(Employee_.id)));
            return cb.like(cb.upper(root.get(Employee_.email)), keyword.toUpperCase());
        }
    };
}

From source file:com.mtt.myapp.user.repository.UserSpecification.java

/**
 * Create "Email like" query spec./*from   w w w .  j a  va2 s. c o m*/
 * @param query query
 * @return created spec
 */
public static Specification<User> emailLike(final String query) {
    return new Specification<User>() {
        @Override
        public Predicate toPredicate(Root<User> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
            String pattern = ("%" + query + "%").toLowerCase();
            return cb.like(cb.lower(root.get("email").as(String.class)), pattern);
        }
    };
}

From source file:com.mtt.myapp.user.repository.UserSpecification.java

/**
 * Create "Name Like" query spec.//from w ww  .  ja v  a  2  s  .  com
 * @param query query
 * @return created spec
 */
public static Specification<User> nameLike(final String query) {
    return new Specification<User>() {
        @Override
        public Predicate toPredicate(Root<User> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
            String pattern = ("%" + query + "%").toLowerCase();
            return cb.or(cb.like(cb.lower(root.get("userName").as(String.class)), pattern),
                    cb.like(cb.lower(root.get("userId").as(String.class)), pattern));
        }
    };
}

From source file:edu.pitt.dbmi.ccd.db.specification.AnnotationTargetSpecification.java

private static Predicate titleContains(Root<AnnotationTarget> root, CriteriaBuilder cb, String term) {
    return cb.like(cb.lower(root.get(TITLE)), term);
}

From source file:edu.pitt.dbmi.ccd.db.specification.AnnotationTargetSpecification.java

private static Predicate addressContains(Root<AnnotationTarget> root, CriteriaBuilder cb, String term) {
    return cb.like(cb.lower(root.get(ADDRESS)), term);
}

From source file:edu.pitt.dbmi.ccd.db.specification.AnnotationTargetSpecification.java

private static Predicate fileNameContains(Root<AnnotationTarget> root, CriteriaBuilder cb, String term) {
    return cb.like(cb.lower(root.get(FILE).get(NAME)), term);
}