当前位置: 首页>>代码示例>>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;未经允许,请勿转载。