All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.blazebit.persistence.spring.data.repository.EntityViewSpecificationExecutor Maven / Gradle / Ivy

/*
 * SPDX-License-Identifier: Apache-2.0
 * Copyright Blazebit
 */

package com.blazebit.persistence.spring.data.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;

import java.util.List;

/**
 * Like {@link org.springframework.data.jpa.repository.JpaSpecificationExecutor} but allows to specify an entity view
 * return type.
 *
 * @param  The view type
 * @param  The entity type
 * @author Moritz Becker
 * @since 1.2.0
 */
public interface EntityViewSpecificationExecutor {

    /**
     * Returns a single view matching the given {@link Specification}.
     *
     * @param spec The specification for filtering
     * @return The matching view
     */
    V findOne(Specification spec);

    /**
     * Returns all views matching the given {@link Specification}.
     *
     * @param spec The specification for filtering
     * @return All matching views
     */
    List findAll(Specification spec);

    /**
     * Returns a {@link Page} of views matching the given {@link Specification}.
     *
     * @param spec The specification for filtering
     * @param pageable The pagination information
     * @return The requested page of matching views
     */
    Page findAll(Specification spec, Pageable pageable);

    /**
     * Returns all views matching the given {@link Specification} in the order defined by {@link Sort}.
     *
     * @param spec The specification for filtering
     * @param sort The sort order definition
     * @return All matching views in the requested order
     */
    List findAll(Specification spec, Sort sort);

    /**
     * Returns the number of instances that the given {@link Specification} will return.
     *
     * @param spec the {@link Specification} to count instances for
     * @return the number of instances
     */
    long count(Specification spec);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy