List of usage examples for javax.persistence.criteria Root get
<Y> Path<Y> get(SingularAttribute<? super X, Y> attribute);
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); }
From source file:org.wallride.repository.CategorySpecifications.java
public static Specification<Category> hasArticle(String language) { return (root, query, cb) -> { query.distinct(true);//from w ww.j a va2s . c o m Subquery<Long> subquery = query.subquery(Long.class); Root<Article> a = subquery.from(Article.class); Join<Article, Category> c = a.join(Article_.categories, JoinType.INNER); subquery.select(c.get(Category_.id)).where(cb.equal(a.get(Article_.status), Article.Status.PUBLISHED)); List<Predicate> predicates = new ArrayList<>(); predicates.add(root.get(Category_.id).in(subquery)); predicates.add(cb.equal(root.get(Category_.language), language)); return cb.and(predicates.toArray(new Predicate[0])); }; }
From source file:com.goodhuddle.huddle.repository.TagSpecification.java
public static Specification<Tag> search(final Huddle huddle, final SearchTagsRequest request) { return new Specification<Tag>() { @Override/* www . ja v a 2 s.com*/ public Predicate toPredicate(Root<Tag> tag, CriteriaQuery<?> query, CriteriaBuilder builder) { Predicate conjunction = builder.conjunction(); conjunction.getExpressions().add(builder.equal(tag.get("huddle"), huddle)); if (StringUtils.isNotBlank(request.getName())) { String nameTerm = "%" + request.getName().toLowerCase() + "%"; conjunction.getExpressions() .add(builder.like(builder.lower(tag.<String>get("name")), nameTerm)); } return conjunction; } }; }
From source file:com.mtt.myapp.user.repository.UserSpecification.java
/** * Create "Name Like" query spec.//from w w w .j av a 2s. c o m * @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 belongsToUser(Root<AnnotationTarget> root, CriteriaBuilder cb, String username) { return cb.like(cb.lower(root.get(USER).get(USERNAME)), username.toLowerCase()); }
From source file:org.ngrinder.perftest.repository.PerfTestSpecification.java
/** * Get the{@link Specification} checking if the {@link PerfTest} has one of given {@link Status}. * * @param statuses status set//from w w w .ja v a 2 s . c om * @return {@link Specification} */ public static Specification<PerfTest> statusSetEqual(final Status... statuses) { return new Specification<PerfTest>() { @Override public Predicate toPredicate(Root<PerfTest> root, CriteriaQuery<?> query, CriteriaBuilder cb) { return root.get("status").in((Object[]) statuses); } }; }
From source file:org.ngrinder.perftest.repository.PerfTestSpecification.java
/** * Get the {@link Specification} checking if the {@link PerfTest} has one of the given IDs. * * @param ids id list/* w w w.j a v a 2 s . com*/ * @return {@link Specification} */ public static Specification<PerfTest> idSetEqual(final Long[] ids) { return new Specification<PerfTest>() { @Override public Predicate toPredicate(Root<PerfTest> root, CriteriaQuery<?> query, CriteriaBuilder cb) { return root.get("id").in((Object[]) ids); } }; }
From source file:org.ngrinder.perftest.repository.PerfTestSpecification.java
/** * Get the {@link Specification} whichs provide empty predicate. * * This is for the base element for "and" or "or" combination. * * @return {@link Specification}//from ww w.j a va2 s . c om */ public static Specification<PerfTest> idEmptyPredicate() { return new Specification<PerfTest>() { @Override public Predicate toPredicate(Root<PerfTest> root, CriteriaQuery<?> query, CriteriaBuilder cb) { return root.get("id").isNotNull(); } }; }
From source file:org.ngrinder.perftest.repository.PerfTestSpecification.java
/** * Get the Specification which provide empty predicate for schedule time. This is for the base element for "and" or * "or" combination.//from w w w . j a v a 2 s. co m * * @return {@link Specification} */ public static Specification<PerfTest> scheduledTimeNotEmptyPredicate() { return new Specification<PerfTest>() { @Override public Predicate toPredicate(Root<PerfTest> root, CriteriaQuery<?> query, CriteriaBuilder cb) { return root.get("scheduledTime").isNotNull(); } }; }