當前位置: 首頁>>代碼示例>>Java>>正文


Java Specification.toPredicate方法代碼示例

本文整理匯總了Java中org.springframework.data.jpa.domain.Specification.toPredicate方法的典型用法代碼示例。如果您正苦於以下問題:Java Specification.toPredicate方法的具體用法?Java Specification.toPredicate怎麽用?Java Specification.toPredicate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.data.jpa.domain.Specification的用法示例。


在下文中一共展示了Specification.toPredicate方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: applySpecificationToQueryCriteria

import org.springframework.data.jpa.domain.Specification; //導入方法依賴的package包/類
/**
 * Spec op query doen.
 * @param spec spec
 * @param query query
 * @param <S> query type
 * @return root
 */
protected final <S> Root<T> applySpecificationToQueryCriteria(final Specification<T> spec, final CriteriaQuery<S> query) {

    Assert.notNull(query, "Query mag niet null zijn.");
    final Root<T> root = query.from(getDomainClass());

    if (spec == null) {
        return root;
    }

    final CriteriaBuilder builder = em.getCriteriaBuilder();
    final Predicate predicate = spec.toPredicate(root, query, builder);

    if (predicate != null) {
        query.where(predicate);
    }

    return root;
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:26,代碼來源:CustomSimpleJpaRepository.java

示例2: aggregate

import org.springframework.data.jpa.domain.Specification; //導入方法依賴的package包/類
private <S> S aggregate(CriteriaBuilder builder, CriteriaQuery<S> query, Root<E> root, Specification<E> spec, List<Selection<?>> selectionList, LockModeType lockMode) {
	if (selectionList != null) {
		Predicate predicate = spec.toPredicate(root, query, builder);
		if (predicate != null) {
			query.where(predicate);
		}
		query.multiselect(selectionList);
		return (S) em.createQuery(query).setLockMode(lockMode).getSingleResult();
	}
	return null;
}
 
開發者ID:onsoul,項目名稱:os,代碼行數:12,代碼來源:GenericRepositoryImpl.java

示例3: toPredicate

import org.springframework.data.jpa.domain.Specification; //導入方法依賴的package包/類
@Override
public Predicate toPredicate(Root<Object> root, CriteriaQuery<?> cq, CriteriaBuilder cb) {
    List<Predicate> predicates = new ArrayList<>();
    for(Specification specification: specifications){
        Predicate p = specification.toPredicate(root, cq, cb);
        if(p!=null)
            predicates.add(p);
    }
    return cb.and(predicates.toArray(new Predicate[predicates.size()]));
}
 
開發者ID:ZhongjunTian,項目名稱:spring-repository-plus,代碼行數:11,代碼來源:SpecificationImpl.java

示例4: applySpecificationToCriteria

import org.springframework.data.jpa.domain.Specification; //導入方法依賴的package包/類
/**
 * Applies the given {@link Specification} to the given {@link CriteriaQuery}.
 */
private <S, T> Root<T> applySpecificationToCriteria(final Root<T> root, final Specification<T> spec, final CriteriaQuery<S> query) {

	Assert.notNull(query, "Query is requested");

	if (spec != null) {
		// There is at least one described filter
		final CriteriaBuilder builder = em.getCriteriaBuilder();
		final Predicate predicate = spec.toPredicate(root, query, builder);

		// There is at least one validated filter
		query.where(predicate);
	}
	return root;
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:18,代碼來源:PaginationDao.java


注:本文中的org.springframework.data.jpa.domain.Specification.toPredicate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。