2828import org .springframework .data .domain .Sort ;
2929import org .springframework .data .jpa .domain .Specification ;
3030import org .springframework .data .repository .query .FluentQuery ;
31+ import org .springframework .lang .Nullable ;
3132
3233/**
3334 * Interface to allow execution of {@link Specification}s based on the JPA criteria API.
@@ -50,37 +51,45 @@ public interface JpaSpecificationExecutor<T> {
5051
5152 /**
5253 * Returns all entities matching the given {@link Specification}.
54+ * <p>
55+ * If no {@link Specification} is given all entities matching {@code <T>} will be selected.
5356 *
54- * @param spec must not be {@literal null}.
57+ * @param spec can be {@literal null}.
5558 * @return never {@literal null}.
5659 */
57- List <T > findAll (Specification <T > spec );
60+ List <T > findAll (@ Nullable Specification <T > spec );
5861
5962 /**
6063 * Returns a {@link Page} of entities matching the given {@link Specification}.
64+ * <p>
65+ * If no {@link Specification} is given all entities matching {@code <T>} will be selected.
6166 *
62- * @param spec must not be {@literal null}.
67+ * @param spec can be {@literal null}.
6368 * @param pageable must not be {@literal null}.
6469 * @return never {@literal null}.
6570 */
66- Page <T > findAll (Specification <T > spec , Pageable pageable );
71+ Page <T > findAll (@ Nullable Specification <T > spec , Pageable pageable );
6772
6873 /**
6974 * Returns all entities matching the given {@link Specification} and {@link Sort}.
75+ * <p>
76+ * If no {@link Specification} is given all entities matching {@code <T>} will be selected.
7077 *
71- * @param spec must not be {@literal null}.
78+ * @param spec can be {@literal null}.
7279 * @param sort must not be {@literal null}.
7380 * @return never {@literal null}.
7481 */
75- List <T > findAll (Specification <T > spec , Sort sort );
82+ List <T > findAll (@ Nullable Specification <T > spec , Sort sort );
7683
7784 /**
7885 * Returns the number of instances that the given {@link Specification} will return.
86+ * <p>
87+ * If no {@link Specification} is given all entities matching {@code <T>} will be counted.
7988 *
8089 * @param spec the {@link Specification} to count instances for, must not be {@literal null}.
8190 * @return the number of instances.
8291 */
83- long count (Specification <T > spec );
92+ long count (@ Nullable Specification <T > spec );
8493
8594 /**
8695 * Checks whether the data store contains elements that match the given {@link Specification}.
@@ -101,12 +110,14 @@ public interface JpaSpecificationExecutor<T> {
101110 * {@link Specification#toPredicate(Root, CriteriaQuery, CriteriaBuilder)} will be {@literal null} because
102111 * {@link jakarta.persistence.criteria.CriteriaBuilder#createCriteriaDelete(Class)} does not implement
103112 * {@code CriteriaQuery}.
113+ * <p>
114+ * If no {@link Specification} is given all entities matching {@code <T>} will be deleted.
104115 *
105- * @param spec the {@link Specification} to use for the existence check, must not be {@literal null}.
116+ * @param spec the {@link Specification} to use for the existence check, can not be {@literal null}.
106117 * @return the number of entities deleted.
107118 * @since 3.0
108119 */
109- long delete (Specification <T > spec );
120+ long delete (@ Nullable Specification <T > spec );
110121
111122 /**
112123 * Returns entities matching the given {@link Specification} applying the {@code queryFunction} that defines the query
0 commit comments