20
20
import io .reactivex .rxjava3 .core .Maybe ;
21
21
import io .reactivex .rxjava3 .core .Single ;
22
22
23
+ import org .springframework .dao .OptimisticLockingFailureException ;
23
24
import org .springframework .data .repository .NoRepositoryBean ;
24
25
import org .springframework .data .repository .Repository ;
25
26
26
27
/**
27
28
* Interface for generic CRUD operations on a repository for a specific type. This repository follows reactive paradigms
28
29
* and uses RxJava 3 types.
29
30
* <p>
30
- * Save and delete operations with entities that have a version attribute trigger an {@code onError} with a {@link org.springframework.dao.OptimisticLockingFailureException} when they encounter a different version value in the persistence store than in the entity passed as an argument.
31
+ * Save and delete operations with entities that have a version attribute trigger an {@code onError} with a
32
+ * {@link org.springframework.dao.OptimisticLockingFailureException} when they encounter a different version value in
33
+ * the persistence store than in the entity passed as an argument.
31
34
* </p>
32
35
* <p>
33
- * Other delete operations that only receive ids or entities without version attribute do not trigger an error when no matching data is found in the persistence store.
36
+ * Other delete operations that only receive ids or entities without version attribute do not trigger an error when no
37
+ * matching data is found in the persistence store.
34
38
* </p>
35
39
*
36
40
* @author Mark Paluch
@@ -50,6 +54,9 @@ public interface RxJava3CrudRepository<T, ID> extends Repository<T, ID> {
50
54
* @param entity must not be {@literal null}.
51
55
* @return {@link Single} emitting the saved entity.
52
56
* @throws IllegalArgumentException in case the given {@literal entity} is {@literal null}.
57
+ * @throws OptimisticLockingFailureException when the entity uses optimistic locking and has a version attribute with
58
+ * a different value from that found in the persistence store. Also thrown if the entity is assumed to be
59
+ * present but does not exist in the database.
53
60
*/
54
61
<S extends T > Single <S > save (S entity );
55
62
@@ -60,6 +67,9 @@ public interface RxJava3CrudRepository<T, ID> extends Repository<T, ID> {
60
67
* @return {@link Flowable} emitting the saved entities.
61
68
* @throws IllegalArgumentException in case the given {@link Iterable entities} or one of its entities is
62
69
* {@literal null}.
70
+ * @throws OptimisticLockingFailureException when at least one entity uses optimistic locking and has a version
71
+ * attribute with a different value from that found in the persistence store. Also thrown if at least one
72
+ * entity is assumed to be present but does not exist in the database.
63
73
*/
64
74
<S extends T > Flowable <S > saveAll (Iterable <S > entities );
65
75
@@ -69,6 +79,9 @@ public interface RxJava3CrudRepository<T, ID> extends Repository<T, ID> {
69
79
* @param entityStream must not be {@literal null}.
70
80
* @return {@link Flowable} emitting the saved entities.
71
81
* @throws IllegalArgumentException in case the given {@link Flowable entityStream} is {@literal null}.
82
+ * @throws OptimisticLockingFailureException when at least one entity uses optimistic locking and has a version
83
+ * attribute with a different value from that found in the persistence store. Also thrown if at least one
84
+ * entity is assumed to be present but does not exist in the database.
72
85
*/
73
86
<S extends T > Flowable <S > saveAll (Flowable <S > entityStream );
74
87
@@ -151,6 +164,8 @@ public interface RxJava3CrudRepository<T, ID> extends Repository<T, ID> {
151
164
152
165
/**
153
166
* Deletes the entity with the given id.
167
+ * <p>
168
+ * If the entity is not found in the persistence store it is silently ignored.
154
169
*
155
170
* @param id must not be {@literal null}.
156
171
* @return {@link Completable} signaling when operation has completed.
@@ -164,11 +179,16 @@ public interface RxJava3CrudRepository<T, ID> extends Repository<T, ID> {
164
179
* @param entity must not be {@literal null}.
165
180
* @return {@link Completable} signaling when operation has completed.
166
181
* @throws IllegalArgumentException in case the given entity is {@literal null}.
182
+ * @throws OptimisticLockingFailureException when the entity uses optimistic locking and has a version attribute with
183
+ * a different value from that found in the persistence store. Also thrown if the entity is assumed to be
184
+ * present but does not exist in the database.
167
185
*/
168
186
Completable delete (T entity );
169
187
170
188
/**
171
189
* Deletes all instances of the type {@code T} with the given IDs.
190
+ * <p>
191
+ * Entities that aren't found in the persistence store are silently ignored.
172
192
*
173
193
* @param ids must not be {@literal null}.
174
194
* @return {@link Completable} signaling when operation has completed.
@@ -185,6 +205,9 @@ public interface RxJava3CrudRepository<T, ID> extends Repository<T, ID> {
185
205
* @return {@link Completable} signaling when operation has completed.
186
206
* @throws IllegalArgumentException in case the given {@link Iterable entities} or one of its entities is
187
207
* {@literal null}.
208
+ * @throws OptimisticLockingFailureException when at least one entity uses optimistic locking and has a version
209
+ * attribute with a different value from that found in the persistence store. Also thrown if at least one
210
+ * entity is assumed to be present but does not exist in the database.
188
211
*/
189
212
Completable deleteAll (Iterable <? extends T > entities );
190
213
@@ -194,6 +217,9 @@ public interface RxJava3CrudRepository<T, ID> extends Repository<T, ID> {
194
217
* @param entityStream must not be {@literal null}.
195
218
* @return {@link Completable} signaling when operation has completed.
196
219
* @throws IllegalArgumentException in case the given {@link Flowable entityStream} is {@literal null}.
220
+ * @throws OptimisticLockingFailureException when at least one entity uses optimistic locking and has a version
221
+ * attribute with a different value from that found in the persistence store. Also thrown if at least one
222
+ * entity is assumed to be present but does not exist in the database.
197
223
*/
198
224
Completable deleteAll (Flowable <? extends T > entityStream );
199
225
0 commit comments