@@ -206,7 +206,6 @@ public ReactiveCassandraBatchOperations insert(Iterable<?> entities, WriteOption
206
206
assertNotExecuted ();
207
207
Assert .notNull (entities , "Entities must not be null" );
208
208
Assert .notNull (options , "WriteOptions must not be null" );
209
- assertNotQueryOptions (entities );
210
209
211
210
addStatements (doInsert (entities , options ));
212
211
@@ -234,6 +233,7 @@ private Collection<SimpleStatement> doInsert(Iterable<?> entities, WriteOptions
234
233
235
234
Assert .notNull (entity , "Entity must not be null" );
236
235
assertNotStatement ("insert" , entity );
236
+ assertNotQueryOptions (entity );
237
237
238
238
BasicCassandraPersistentEntity <?> persistentEntity = mappingContext
239
239
.getRequiredPersistentEntity (entity .getClass ());
@@ -271,7 +271,6 @@ public ReactiveCassandraBatchOperations update(Iterable<?> entities, WriteOption
271
271
assertNotExecuted ();
272
272
Assert .notNull (entities , "Entities must not be null" );
273
273
Assert .notNull (options , "WriteOptions must not be null" );
274
- assertNotQueryOptions (entities );
275
274
276
275
addStatements (Mono .just (doUpdate (entities , options )));
277
276
@@ -298,6 +297,7 @@ private Collection<SimpleStatement> doUpdate(Iterable<?> entities, WriteOptions
298
297
299
298
Assert .notNull (entity , "Entity must not be null" );
300
299
assertNotStatement ("update" , entity );
300
+ assertNotQueryOptions (entity );
301
301
302
302
CassandraPersistentEntity <?> persistentEntity = getRequiredPersistentEntity (entity .getClass ());
303
303
@@ -334,7 +334,6 @@ public ReactiveCassandraBatchOperations delete(Iterable<?> entities, WriteOption
334
334
assertNotExecuted ();
335
335
Assert .notNull (entities , "Entities must not be null" );
336
336
Assert .notNull (options , "WriteOptions must not be null" );
337
- assertNotQueryOptions (entities );
338
337
339
338
addStatements (Mono .just (doDelete (entities , options )));
340
339
@@ -353,17 +352,6 @@ public ReactiveCassandraBatchOperations delete(Mono<? extends Iterable<?>> entit
353
352
return this ;
354
353
}
355
354
356
- private void assertNotQueryOptions (Iterable <?> entities ) {
357
-
358
- for (Object entity : entities ) {
359
- if (entity instanceof QueryOptions ) {
360
- throw new IllegalArgumentException (
361
- String .format ("%s must not be used as entity; Please make sure to call the appropriate method accepting %s" ,
362
- ClassUtils .getDescriptiveType (entity ), ClassUtils .getShortName (entity .getClass ())));
363
- }
364
- }
365
- }
366
-
367
355
private Collection <SimpleStatement > doDelete (Iterable <?> entities , WriteOptions options ) {
368
356
369
357
List <SimpleStatement > deleteQueries = new ArrayList <>();
@@ -372,6 +360,7 @@ private Collection<SimpleStatement> doDelete(Iterable<?> entities, WriteOptions
372
360
373
361
Assert .notNull (entity , "Entity must not be null" );
374
362
assertNotStatement ("delete" , entity );
363
+ assertNotQueryOptions (entity );
375
364
376
365
CassandraPersistentEntity <?> persistentEntity = getRequiredPersistentEntity (entity .getClass ());
377
366
@@ -383,4 +372,21 @@ private Collection<SimpleStatement> doDelete(Iterable<?> entities, WriteOptions
383
372
384
373
return deleteQueries ;
385
374
}
375
+
376
+ private static void assertNotQueryOptions (Object o ) {
377
+
378
+ if (o instanceof QueryOptions ) {
379
+ throw new IllegalArgumentException (
380
+ String .format ("%s must not be used as entity; Please make sure to call the appropriate method accepting %s" ,
381
+ ClassUtils .getDescriptiveType (o ), ClassUtils .getShortName (o .getClass ())));
382
+ }
383
+ }
384
+
385
+ private static void assertNotStatement (String operation , Object o ) {
386
+
387
+ if (o instanceof Statement <?>) {
388
+ throw new IllegalArgumentException (String .format ("%s cannot use a Statement: %s. Use only entities for %s" ,
389
+ StringUtils .capitalize (operation ), ClassUtils .getDescriptiveType (o ), operation ));
390
+ }
391
+ }
386
392
}
0 commit comments