Skip to content

Commit 8f3a262

Browse files
committed
DATACASS-833 - Deprecate cached PreparedStatementCreator support classes.
Since Cassandra driver version 4, the driver itself tracks prepared statements so external prepared statement caching is no longer required.
1 parent ed46d74 commit 8f3a262

File tree

6 files changed

+20
-16
lines changed

6 files changed

+20
-16
lines changed

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/CachedPreparedStatementCreator.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@
1818
import java.util.Map;
1919
import java.util.concurrent.ConcurrentHashMap;
2020

21-
import com.datastax.oss.driver.api.core.CqlIdentifier;
22-
import com.datastax.oss.driver.api.core.CqlSession;
23-
import com.datastax.oss.driver.api.core.DriverException;
24-
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
2521
import org.slf4j.Logger;
2622
import org.slf4j.LoggerFactory;
2723

2824
import org.springframework.util.Assert;
2925

26+
import com.datastax.oss.driver.api.core.CqlIdentifier;
27+
import com.datastax.oss.driver.api.core.CqlSession;
28+
import com.datastax.oss.driver.api.core.DriverException;
29+
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
30+
3031
/**
3132
* This {@link PreparedStatementCreator} maintains a static cache of all prepared statements for the duration of the JVM
3233
* runtime, more specific the lifecycle of the associated {@link ClassLoader}. When preparing statements with Cassandra,
@@ -38,8 +39,7 @@
3839
* @author David Webb
3940
* @author Mark Paluch
4041
* @deprecated since 2.0. This class uses an unsafe, static held cache and is not able to prepare
41-
* {@link com.datastax.driver.core.querybuilder.BuiltStatement}. Use
42-
* {@link org.springframework.data.cassandra.core.cql.support.CachedPreparedStatementCreator}.
42+
* {@link com.datastax.driver.core.querybuilder.BuiltStatement}.
4343
*/
4444
@Deprecated
4545
public class CachedPreparedStatementCreator implements PreparedStatementCreator {

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/SimplePreparedStatementCreator.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,11 @@
2424

2525
/**
2626
* Trivial implementation of {@link PreparedStatementCreator}. This prepared statement creator simply prepares a
27-
* statement from the CQL string.
28-
* <p>
29-
* This implementation is useful for testing. It should not be used in production systems with high volume reads and
30-
* writes. Use {@link CachedPreparedStatementCreator} When preparing statements with Cassandra, each Statement should be
31-
* prepared once and only once due to the overhead of preparing the statement.
27+
* statement from the CQL string. Exposes the given CQL statement through {@link CqlProvider#getCql()},
3228
*
3329
* @author David Webb
3430
* @author Mark Paluch
31+
* @see CqlProvider
3532
*/
3633
public class SimplePreparedStatementCreator implements PreparedStatementCreator, CqlProvider {
3734

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/support/CachedPreparedStatementCreator.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
*/
1616
package org.springframework.data.cassandra.core.cql.support;
1717

18+
import org.springframework.data.cassandra.core.cql.PreparedStatementCreator;
19+
import org.springframework.data.cassandra.core.cql.QueryOptions;
20+
import org.springframework.util.Assert;
21+
1822
import com.datastax.oss.driver.api.core.CqlSession;
1923
import com.datastax.oss.driver.api.core.DriverException;
2024
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
2125
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
2226
import com.datastax.oss.driver.api.core.cql.Statement;
2327

24-
import org.springframework.data.cassandra.core.cql.PreparedStatementCreator;
25-
import org.springframework.data.cassandra.core.cql.QueryOptions;
26-
import org.springframework.util.Assert;
27-
2828
/**
2929
* {@link PreparedStatementCreator} implementation using caching of prepared statements.
3030
* <p />
@@ -35,7 +35,9 @@
3535
* @author Mark Paluch
3636
* @since 2.0
3737
* @see PreparedStatementCache
38+
* @deprecated since 3.2, the Cassandra driver has a built-in prepared statement cache with makes external caching of prepared statements superfluous.
3839
*/
40+
@Deprecated
3941
public class CachedPreparedStatementCreator implements PreparedStatementCreator {
4042

4143
private final PreparedStatementCache cache;

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/support/MapPreparedStatementCache.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
* @author Mark Paluch
3737
* @author Aldo Bongio
3838
* @since 2.0
39+
* @deprecated since 3.2, the Cassandra driver has a built-in prepared statement cache with makes external caching of prepared statements superfluous.
3940
*/
41+
@Deprecated
4042
public class MapPreparedStatementCache implements PreparedStatementCache {
4143

4244
private final Map<CacheKey, PreparedStatement> cache;

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/support/PreparedStatementCache.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
* @author Mark Paluch
3232
* @since 2.0
3333
* @see PreparedStatement
34+
* @deprecated since 3.2, the Cassandra driver has a built-in prepared statement cache with makes external caching of
35+
* prepared statements superfluous.
3436
*/
37+
@Deprecated
3538
public interface PreparedStatementCache {
3639

3740
/**

src/main/asciidoc/reference/reactive-cassandra.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Spring Data for Apache Cassandra uses consistent naming conventions on objects i
1818
[[cassandra.reactive.getting-started]]
1919
== Getting Started
2020

21-
Spring Data for Apache Cassandra requires Apache Cassandra 2.1 or later and Datastax Java Driver 3.0 or later.
21+
Spring Data for Apache Cassandra requires Apache Cassandra 2.1 or later and Datastax Java Driver 4.0 or later.
2222
An easy way to quickly set up and bootstrap a working environment is to create a Spring-based project in https://spring.io/tools/sts[STS] or use https://start.spring.io/[Spring Initializer].
2323

2424
First, you need to set up a running Apache Cassandra server.

0 commit comments

Comments
 (0)