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


Java JpaSpecificationExecutor類代碼示例

本文整理匯總了Java中org.springframework.data.jpa.repository.JpaSpecificationExecutor的典型用法代碼示例。如果您正苦於以下問題:Java JpaSpecificationExecutor類的具體用法?Java JpaSpecificationExecutor怎麽用?Java JpaSpecificationExecutor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JpaSpecificationExecutor類屬於org.springframework.data.jpa.repository包,在下文中一共展示了JpaSpecificationExecutor類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: groupRelationsInternal

import org.springframework.data.jpa.repository.JpaSpecificationExecutor; //導入依賴的package包/類
private static <T, U, V> Map<V, List<U>> groupRelationsInternal(
        @Nonnull final Collection<? extends T> objects,
        @Nonnull final Specification<U> inSpec,
        @Nonnull final JpaSpecificationExecutor<U> repository,
        @Nonnull final Function<? super U, ? extends V> keyMapper,
        @Nullable final Specification<U> constraint,
        @Nullable final Sort sortCriteria) {

    Objects.requireNonNull(objects, "objects must not be null");
    Objects.requireNonNull(inSpec, "inSpec must not be null");
    Objects.requireNonNull(repository, "repository must not be null");

    if (objects.isEmpty()) {
        return new HashMap<>(0);
    }

    final Specification<U> compoundSpec =
            constraint == null ? inSpec : Specifications.where(inSpec).and(constraint);

    final List<U> list = sortCriteria != null
            ? repository.findAll(compoundSpec, sortCriteria) : repository.findAll(compoundSpec);
    return F.nullSafeGroupBy(list, keyMapper);
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-web,代碼行數:24,代碼來源:JpaGroupingUtils.java

示例2: selectFrom

import org.springframework.data.jpa.repository.JpaSpecificationExecutor; //導入依賴的package包/類
public static <ENTITY, REPO extends JpaRepository<ENTITY, ?> & JpaSpecificationExecutor>
SpecificationBuilder<ENTITY> selectFrom(REPO repository) {
    SpecificationBuilder<ENTITY> builder = new SpecificationBuilder<>();
    builder.repository = repository;
    builder.specification = new SpecificationImpl();
    return builder;
}
 
開發者ID:ZhongjunTian,項目名稱:spring-repository-plus,代碼行數:8,代碼來源:SpecificationBuilder.java

示例3: selectDistinctFrom

import org.springframework.data.jpa.repository.JpaSpecificationExecutor; //導入依賴的package包/類
public static <ENTITY, REPO extends JpaRepository<ENTITY, ?> & JpaSpecificationExecutor>
SpecificationBuilder<ENTITY> selectDistinctFrom(REPO repository) {
    SpecificationBuilder<ENTITY> builder = selectFrom(repository);
    builder.distinct();
    return builder;
}
 
開發者ID:ZhongjunTian,項目名稱:spring-repository-plus,代碼行數:7,代碼來源:SpecificationBuilder.java

示例4: groupRelations

import org.springframework.data.jpa.repository.JpaSpecificationExecutor; //導入依賴的package包/類
@Nonnull
public static <T, U> Map<T, List<U>> groupRelations(
        @Nonnull final Collection<? extends T> objects,
        @Nonnull final SingularAttribute<? super U, T> singularAttribute,
        @Nonnull final JpaSpecificationExecutor<U> repository) {

    return groupRelations(objects, singularAttribute, repository, null, null);
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-web,代碼行數:9,代碼來源:JpaGroupingUtils.java

示例5: groupRelationsById

import org.springframework.data.jpa.repository.JpaSpecificationExecutor; //導入依賴的package包/類
@Nonnull
public static <ID extends Serializable, T extends HasID<ID>, U> Map<ID, List<U>> groupRelationsById(
        @Nonnull final Collection<? extends T> objects,
        @Nonnull final SingularAttribute<? super U, T> singularAttribute,
        @Nonnull final JpaSpecificationExecutor<U> repository) {

    return groupRelationsById(objects, singularAttribute, repository, null, null);
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-web,代碼行數:9,代碼來源:JpaGroupingUtils.java

示例6: createInverseMappingFunction

import org.springframework.data.jpa.repository.JpaSpecificationExecutor; //導入依賴的package包/類
public static <ID extends Serializable, T extends HasID<ID>, U> Function<T, List<U>> createInverseMappingFunction(
        @Nonnull final Collection<? extends T> objects,
        @Nonnull final SingularAttribute<? super U, T> singularAttribute,
        @Nonnull final JpaSpecificationExecutor<U> repository,
        final boolean letFunctionThrowExceptionOnEmptyResult) {

    return createInverseMappingFunction(
            objects, singularAttribute, repository, null, letFunctionThrowExceptionOnEmptyResult);
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-web,代碼行數:10,代碼來源:JpaGroupingUtils.java

示例7: getPage

import org.springframework.data.jpa.repository.JpaSpecificationExecutor; //導入依賴的package包/類
/**
 * 根據 customSpecification,進行分頁查詢。
 * <p>
 * findAll() 方法,會進行兩次查詢,先做 count 查詢,之後是具體查詢,所以 Page 中包含了總數和具體查詢結果集
 *
 * @param repository          查詢器
 * @param currentPageNo       當前頁,實際對應 jqgrid 傳遞過來的 page 參數,jqgrid 規定起始頁為 1
 * @param pageSize            頁麵可顯示行數
 * @param sort
 * @param customSpecification 除了 jqgrid 傳遞過來的查詢條件外,自己又附加查詢條件,與 filters AND 關係的查詢條件,specification 的構造符合 SearchFilter 寫法,詳見示例項目。
 *                            customSpecification 中指定的屬性名稱應該是待查詢的 entity 中的屬性名稱,並且用改 entity 的 repository 進行查詢
 * @return
 */

public static Page getPage(JpaSpecificationExecutor repository, int currentPageNo, int pageSize, Sort sort, Specification customSpecification) {

    //jpa 中起始頁為 0,但傳遞過來的參數 currentPageNo 不能小於1
    Assert.isTrue(currentPageNo >= 1, "currentPageNo  需要 >= 1 ");
    currentPageNo = currentPageNo - 1;
    return repository.findAll(customSpecification, new PageRequest(currentPageNo, pageSize, sort));


}
 
開發者ID:h819,項目名稱:spring-boot,代碼行數:24,代碼來源:JpaUtils.java


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