28
28
import org .springframework .data .domain .Sort ;
29
29
import org .springframework .data .jpa .domain .Specification ;
30
30
import org .springframework .data .repository .query .FluentQuery ;
31
+ import org .springframework .lang .Nullable ;
31
32
32
33
/**
33
34
* Interface to allow execution of {@link Specification}s based on the JPA criteria API.
@@ -50,37 +51,45 @@ public interface JpaSpecificationExecutor<T> {
50
51
51
52
/**
52
53
* 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.
53
56
*
54
- * @param spec must not be {@literal null}.
57
+ * @param spec can be {@literal null}.
55
58
* @return never {@literal null}.
56
59
*/
57
- List <T > findAll (Specification <T > spec );
60
+ List <T > findAll (@ Nullable Specification <T > spec );
58
61
59
62
/**
60
63
* 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.
61
66
*
62
- * @param spec must not be {@literal null}.
67
+ * @param spec can be {@literal null}.
63
68
* @param pageable must not be {@literal null}.
64
69
* @return never {@literal null}.
65
70
*/
66
- Page <T > findAll (Specification <T > spec , Pageable pageable );
71
+ Page <T > findAll (@ Nullable Specification <T > spec , Pageable pageable );
67
72
68
73
/**
69
74
* 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.
70
77
*
71
- * @param spec must not be {@literal null}.
78
+ * @param spec can be {@literal null}.
72
79
* @param sort must not be {@literal null}.
73
80
* @return never {@literal null}.
74
81
*/
75
- List <T > findAll (Specification <T > spec , Sort sort );
82
+ List <T > findAll (@ Nullable Specification <T > spec , Sort sort );
76
83
77
84
/**
78
85
* 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.
79
88
*
80
89
* @param spec the {@link Specification} to count instances for, must not be {@literal null}.
81
90
* @return the number of instances.
82
91
*/
83
- long count (Specification <T > spec );
92
+ long count (@ Nullable Specification <T > spec );
84
93
85
94
/**
86
95
* Checks whether the data store contains elements that match the given {@link Specification}.
@@ -101,12 +110,14 @@ public interface JpaSpecificationExecutor<T> {
101
110
* {@link Specification#toPredicate(Root, CriteriaQuery, CriteriaBuilder)} will be {@literal null} because
102
111
* {@link jakarta.persistence.criteria.CriteriaBuilder#createCriteriaDelete(Class)} does not implement
103
112
* {@code CriteriaQuery}.
113
+ * <p>
114
+ * If no {@link Specification} is given all entities matching {@code <T>} will be deleted.
104
115
*
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}.
106
117
* @return the number of entities deleted.
107
118
* @since 3.0
108
119
*/
109
- long delete (Specification <T > spec );
120
+ long delete (@ Nullable Specification <T > spec );
110
121
111
122
/**
112
123
* Returns entities matching the given {@link Specification} applying the {@code queryFunction} that defines the query
0 commit comments