Polishing.
Reflect that prepared statements do not inherit query options to avoid cache pollution. See #1335
This commit is contained in:
@@ -982,6 +982,9 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
|
||||
|
||||
@Override
|
||||
public PreparedStatement createPreparedStatement(CqlSession session) throws DriverException {
|
||||
|
||||
// Note that prepared statement settings like the keyspace are gone because using the prepare method with a
|
||||
// statement object causes cache pollution
|
||||
return session.prepare(statement.getQuery());
|
||||
}
|
||||
|
||||
|
||||
@@ -966,6 +966,9 @@ public class ReactiveCassandraTemplate
|
||||
|
||||
@Override
|
||||
public Mono<PreparedStatement> createPreparedStatement(ReactiveSession session) throws DriverException {
|
||||
|
||||
// Note that prepared statement settings like the keyspace are gone because using the prepare method with a
|
||||
// statement object causes cache pollution
|
||||
return session.prepare(statement.getQuery());
|
||||
}
|
||||
|
||||
|
||||
@@ -492,11 +492,14 @@ class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrat
|
||||
|
||||
User user = new User("heisenberg", "Walter", "White");
|
||||
template.insert(user);
|
||||
template.setUsePreparedStatements(false);
|
||||
|
||||
Query query = Query.query(where("id").is("heisenberg")).queryOptions(queryOptions);
|
||||
assertThatThrownBy(() -> assertThat(template.select(query, User.class)).isEmpty())
|
||||
.isInstanceOf(CassandraInvalidQueryException.class)
|
||||
.hasMessageContaining("Keyspace 'non_existing' does not exist");
|
||||
|
||||
template.setUsePreparedStatements(true);
|
||||
}
|
||||
|
||||
@Test // DATACASS-182
|
||||
|
||||
Reference in New Issue
Block a user