Java Code Examples for javax.persistence.criteria.AbstractQuery#having()
The following examples show how to use
javax.persistence.criteria.AbstractQuery#having() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LinqImpl.java From linq with Apache License 2.0 | 6 votes |
protected void applyPredicateToCriteria(AbstractQuery<?> query) { Predicate predicate = parsePredicate(junction); if (predicate != null) { query.where(predicate); } predicate = parsePredicate(having); if (predicate != null) { query.having(predicate); } if (query instanceof CriteriaQuery) { if (!CollectionUtils.isEmpty(orders)) { ((CriteriaQuery<?>) query).orderBy(orders); } } }
Example 2
Source File: LinqImpl.java From bdf3 with Apache License 2.0 | 6 votes |
protected void applyPredicateToCriteria(AbstractQuery<?> query) { Predicate predicate = parsePredicate(junction); if (predicate != null) { query.where(predicate); } predicate = parsePredicate(having); if (predicate != null) { query.having(predicate); } if (query instanceof CriteriaQuery) { if (!CollectionUtils.isEmpty(orders)) { ((CriteriaQuery<?>) query).orderBy(orders); } } }
Example 3
Source File: PredicateUtils.java From genie with Apache License 2.0 | 5 votes |
static <E extends BaseEntity> Predicate createCriterionPredicate( final Root<E> root, final AbstractQuery<?> cq, final CriteriaBuilder cb, final SingularAttribute<UniqueIdEntity, String> uniqueIdAttribute, final SingularAttribute<BaseEntity, String> nameAttribute, final SingularAttribute<BaseEntity, String> versionAttribute, final SingularAttribute<BaseEntity, String> statusAttribute, final Supplier<Join<E, TagEntity>> tagJoinSupplier, final SingularAttribute<IdEntity, Long> idAttribute, final Criterion criterion ) { final List<Predicate> predicates = Lists.newArrayList(); criterion.getId().ifPresent(id -> predicates.add(cb.equal(root.get(uniqueIdAttribute), id))); criterion.getName().ifPresent(name -> predicates.add(cb.equal(root.get(nameAttribute), name))); criterion.getVersion().ifPresent(version -> predicates.add(cb.equal(root.get(versionAttribute), version))); criterion.getStatus().ifPresent(status -> predicates.add(cb.equal(root.get(statusAttribute), status))); final Set<String> tags = criterion.getTags(); if (!tags.isEmpty()) { final Join<E, TagEntity> tagJoin = tagJoinSupplier.get(); predicates.add(tagJoin.get(TagEntity_.tag).in(tags)); cq.groupBy(root.get(idAttribute)); cq.having( cb.equal( cb.count(root.get(idAttribute)), tags.size() ) ); } return cb.and(predicates.toArray(new Predicate[0])); }