Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow keyspace customization for CassandraPersistentEntity #921

Closed
Assignees
Labels
Milestone
@spring-projects-issues

Description

lmcdasi opened DATACASS-751 and commented

In the data stax 4.5 manual it is indicated that creating session/keyspace (https://docs.datastax.com/en/developer/java-driver/4.5/manual/core/) is an anti-pattern:

"// Anti-pattern: creating two sessions doubles the number of TCP connections opened by the driver"

You have a solution that uses the AbstractRoutingSessionFactory that just implement that anti-pattern.

But the data stax driver provides actually two different solutions to avoid having that antipattern.

  1. use the setKeypace when creating a Statement - but this is OK only if the version supported if > V4. Which would not be available for all.
  2. use the built-in QueryBuilder queries that have the keyspace as a parameter. Example: looking at the QueryBuilder.insertInto - it could be changed to use the keyspace since the insertInto signature allows for a a keyspace & a table name. The Statement builder will then build the query by having the keyspace + "." + tablename.

The impacted classes are CassandraTemplate & StatementFactory. I attach example code of above where I test the insertTo successfully.

At the same time, while the framework allows me in CassandraConfig to specify a bean to create a cassandraTemplate that can be different than the default CassandraTemplate it does not allow me to re-use the existing framework classes in order to implement my self a template & statement factory where I can specify the keyspace without being forced to copy them out of the framework.

The keyspace can be kept in a ThreadLocal - using the same principle used for AbstractRoutingSessionFactory .

If we cannot have a template as such in the framework, can we at least have the possibility to implement a CassandraTemplace without being forced to copy a lot of code in order to access the existing framework classes ? The template requires quite a few classes that are private.

This assumes that the keyspace schema are the same.

Thank you


Affects: 3.0 RC1 (Neumann)

Attachments:

1 votes, 4 watchers

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    AltStyle によって変換されたページ (->オリジナル) /