1515 */
1616package org .springframework .data .cassandra .core .cql ;
1717
18- import reactor .core .publisher .Flux ;
19- import reactor .core .publisher .Mono ;
20-
2118import java .util .Map ;
2219import java .util .Optional ;
2320import java .util .function .Function ;
2421
25- import org .reactivestreams .Publisher ;
26-
27- import org .springframework .dao .DataAccessException ;
28- import org .springframework .dao .support .DataAccessUtils ;
29- import org .springframework .data .cassandra .ReactiveResultSet ;
30- import org .springframework .data .cassandra .ReactiveSession ;
31- import org .springframework .data .cassandra .ReactiveSessionFactory ;
32- import org .springframework .data .cassandra .core .cql .session .DefaultReactiveSessionFactory ;
33- import org .springframework .lang .Nullable ;
34- import org .springframework .util .Assert ;
35-
3622import com .datastax .oss .driver .api .core .ConsistencyLevel ;
3723import com .datastax .oss .driver .api .core .CqlIdentifier ;
3824import com .datastax .oss .driver .api .core .CqlSession ;
4430import com .datastax .oss .driver .api .core .cql .SimpleStatement ;
4531import com .datastax .oss .driver .api .core .cql .Statement ;
4632import com .datastax .oss .driver .api .core .retry .RetryPolicy ;
33+ import org .reactivestreams .Publisher ;
34+ import reactor .core .publisher .Flux ;
35+ import reactor .core .publisher .Mono ;
36+
37+ import org .springframework .dao .DataAccessException ;
38+ import org .springframework .dao .support .DataAccessUtils ;
39+ import org .springframework .data .cassandra .ReactiveResultSet ;
40+ import org .springframework .data .cassandra .ReactiveSession ;
41+ import org .springframework .data .cassandra .ReactiveSessionFactory ;
42+ import org .springframework .data .cassandra .core .cql .session .DefaultReactiveSessionFactory ;
43+ import org .springframework .lang .Nullable ;
44+ import org .springframework .util .Assert ;
4745
4846/**
4947 * <b>This is the central class in the CQL core package for reactive Cassandra data access.</b> It simplifies the use of
@@ -303,7 +301,7 @@ public <T> Flux<T> execute(ReactiveSessionCallback<T> action) throws DataAccessE
303301
304302 Assert .notNull (action , "Callback object must not be null" );
305303
306- return createFlux (action ).onErrorMap (translateException ("ReactiveSessionCallback" , getCql (action )));
304+ return createFlux (action ).onErrorMap (translateException ("ReactiveSessionCallback" , toCql (action )));
307305 }
308306
309307 // -------------------------------------------------------------------------
@@ -440,11 +438,12 @@ public <T> Flux<T> query(Statement<?> statement, ReactiveResultSetExtractor<T> r
440438 return createFlux (statement , (session , stmt ) -> {
441439
442440 if (logger .isDebugEnabled ()) {
443- logger .debug ("Executing statement [{} ]" , QueryExtractorDelegate . getCql (statement ));
441+ logger .debug (String . format ( "Executing statement [%s ]" , toCql (statement ) ));
444442 }
445443
446- return session .execute (applyStatementSettings (statement )).flatMapMany (rse ::extractData );
447- }).onErrorMap (translateException ("Query" , statement .toString ()));
444+ return session .execute (applyStatementSettings (statement ))
445+ .flatMapMany (rse ::extractData );
446+ }).onErrorMap (translateException ("Query" , toCql (statement )));
448447 }
449448
450449 /* (non-Javadoc)
@@ -507,17 +506,17 @@ public Mono<ReactiveResultSet> queryForResultSet(Statement<?> statement) throws
507506 return createMono (statement , (session , executedStatement ) -> {
508507
509508 if (logger .isDebugEnabled ()) {
510- logger .debug ("Executing statement [{} ]" , QueryExtractorDelegate . getCql (statement ));
509+ logger .debug (String . format ( "Executing statement [%s ]" , toCql (statement ) ));
511510 }
512511
513512 return session .execute (applyStatementSettings (executedStatement ));
514- }).onErrorMap (translateException ("QueryForResultSet" , statement . toString ( )));
513+ }).onErrorMap (translateException ("QueryForResultSet" , toCql ( statement )));
515514 }
516515
517516 @ Override
518517 public Flux <Row > queryForRows (Statement <?> statement ) throws DataAccessException {
519518 return queryForResultSet (statement ).flatMapMany (ReactiveResultSet ::rows )
520- .onErrorMap (translateException ("QueryForRows" , statement . toString ( )));
519+ .onErrorMap (translateException ("QueryForRows" , toCql ( statement )));
521520 }
522521
523522 // -------------------------------------------------------------------------
@@ -536,10 +535,11 @@ public <T> Flux<T> execute(ReactivePreparedStatementCreator psc, ReactivePrepare
536535
537536 return createFlux (session -> {
538537
539- logger .debug ("Preparing statement [{} ] using {} " , getCql (psc ), psc );
538+ logger .debug (String . format ( "Preparing statement [%s ] using %s " , toCql (psc ), psc ) );
540539
541- return psc .createPreparedStatement (session ).flatMapMany (ps -> action .doInPreparedStatement (session , ps ));
542- }).onErrorMap (translateException ("ReactivePreparedStatementCallback" , getCql (psc )));
540+ return psc .createPreparedStatement (session )
541+ .flatMapMany (ps -> action .doInPreparedStatement (session , ps ));
542+ }).onErrorMap (translateException ("ReactivePreparedStatementCallback" , toCql (psc )));
543543 }
544544
545545 /* (non-Javadoc)
@@ -570,15 +570,15 @@ public <T> Flux<T> query(ReactivePreparedStatementCreator psc,
570570 return execute (psc , (session , preparedStatement ) -> Mono .just (preparedStatement ).flatMapMany (pps -> {
571571
572572 if (logger .isDebugEnabled ()) {
573- logger .debug ("Executing prepared statement [{} ]" , QueryExtractorDelegate . getCql (preparedStatement ));
573+ logger .debug (String . format ( "Executing prepared statement [%s ]" , toCql (preparedStatement ) ));
574574 }
575575
576576 BoundStatement boundStatement = (preparedStatementBinder != null
577577 ? preparedStatementBinder .bindValues (preparedStatement )
578578 : preparedStatement .bind ());
579579
580580 return session .execute (applyStatementSettings (boundStatement ));
581- }).flatMap (rse ::extractData )).onErrorMap (translateException ("Query" , getCql (psc )));
581+ }).flatMap (rse ::extractData )).onErrorMap (translateException ("Query" , toCql (psc )));
582582 }
583583
584584 /* (non-Javadoc)
@@ -738,7 +738,7 @@ public Flux<Boolean> execute(String cql, Publisher<Object[]> args) throws DataAc
738738 return execute (newReactivePreparedStatementCreator (cql ), (session , ps ) -> Flux .from (args ).flatMap (objects -> {
739739
740740 if (logger .isDebugEnabled ()) {
741- logger .debug ("Executing prepared CQL statement [{} ]" , cql );
741+ logger .debug (String . format ( "Executing prepared CQL statement [%s ]" , cql ) );
742742 }
743743
744744 BoundStatement boundStatement = newArgPreparedStatementBinder (objects ).bindValues (ps );
@@ -909,18 +909,6 @@ private Mono<ReactiveSession> getSession() {
909909 return sessionFactory .getSession ();
910910 }
911911
912- /**
913- * Determine CQL from potential provider object.
914- *
915- * @param cqlProvider object that's potentially a {@link CqlProvider}
916- * @return the CQL string, or {@literal null}
917- * @see CqlProvider
918- */
919- @ Nullable
920- private static String getCql (@ Nullable Object cqlProvider ) {
921- return QueryExtractorDelegate .getCql (cqlProvider );
922- }
923-
924912 static class SimpleReactivePreparedStatementCreator implements ReactivePreparedStatementCreator , CqlProvider {
925913
926914 private final SimpleStatement statement ;
0 commit comments