spring-projects / spring-data-cassandra

Provides support to increase developer productivity in Java when using Apache Cassandra. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-cassandra/
Apache License 2.0
376 stars 309 forks source link

Support for QueryOptions and WriteOptions with repository query methods [DATACASS-145] #322

Closed spring-projects-issues closed 6 years ago

spring-projects-issues commented 10 years ago

Jens Rantil opened DATACASS-145 and commented

Background:

Currently it looks the only way to use a custom consistency level is to implement a custom repository. This makes much of the common functionality that spring-data usually comes with unusable


Issue Links:

Referenced from: pull request https://github.com/spring-projects/spring-data-cassandra/pull/113

3 votes, 11 watchers

spring-projects-issues commented 9 years ago

Matthew T. Adams commented

Just filed https://datastax-oss.atlassian.net/browse/JAVA-448. I'd like to get DataStax's feedback before continuing with this work, as it's not an ideal situation

spring-projects-issues commented 9 years ago

Jens Rantil commented

Looks like the feature discussed in the Datastax issue has been added: https://datastax-oss.atlassian.net/browse/JAVA-448?focusedCommentId=18347&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-18347

spring-projects-issues commented 9 years ago

Jason Liu commented

I saw both links before landed on this page. Any ETA on this feature? We need to make a decision on either wait for it or rewrite the db layer. Thanks!

spring-projects-issues commented 9 years ago

Kamlesh Sangani commented

Any update on this? I see DATACASS-145 branch has default QueryOption support added

spring-projects-issues commented 8 years ago

Dennis Effing commented

I can see why this is problematic for TTL and timestamp options but I don't see why especially setting a custom consistency level or retry policy can't be implemented.

Yes, you have to parse CQL for TTL and timestamp but this isn't necessary for the consistency level or retry policy. Could you consider to at least implement the support for custom consistency levels and retry policies without TTL and timestamp options or is there another issue I am missing? I'd appreciate an update on this, thanks

spring-projects-issues commented 8 years ago

Mark Paluch commented

We will come up with a solution.

Query options support fetch size, read timeout and a tracing flag, so I see two possible approaches here: Using annotations

@Consistency(ConsistencyLevel.QUORUM)
List<Person> findPersonByFirstname(String firstname);

or additional arguments:

List<Person> findPersonByFirstname(String firstname, QueryOptions options);

Person save(Person person, WriteOptions writeOptions);
spring-projects-issues commented 8 years ago

Dennis Effing commented

Thank you very much for the update! Those suggestions sound both pretty good to me. I think the best way would be to implement both approaches, where the additional argument always takes precedence over the annotation. This would be the most versatile solution and enable you to adjust the levels even for different situations in your use case

spring-projects-issues commented 7 years ago

Mark Paluch commented

Intermediate update: As of 2.0.0M1, ConsistencyLevel, fetchSize and RetryPolicy can be set on CqlTemplate-level, see http://docs.spring.io/spring-data/cassandra/docs/2.0.0.M1/api/org/springframework/cassandra/support/CassandraAccessor.html

spring-projects-issues commented 7 years ago

Mark Paluch commented

We will open up SimpleReactiveCassandraRepository and SimpleCassandraRepository for simpler extension. Base classes can be extended using our repository base class extension mechanism. As stated above, we introduced a set of customizations to CqlTemplate (used by CassandraTemplate) in an earlier release.

If you require further customization, then please open a follow-up ticket to discuss details in there

spring-projects-issues commented 6 years ago

John Blum commented

PR #113 reviewed, polished and merge to master for the Spring Data *Kay GA release

spring-projects-issues commented 6 years ago

Łukasz Rżanek commented

A quick question regarding this as I cannot find a solution. I am trying to use Cassandra repositories and extend them to support TTL for some insert/save operations. But, quite frankly, I couldn't find any support in the source code for this except template usage. Some experimenting was done, and I cannot find any support for TTL in the insert/save operations on Repository level. Am I missing the elephant in the room or this support got, in the end, limited to QueryOptions for find* methods? Or was it shut down all together?

Sorry for bringing it up, but TTL is a must for us in the project, whether we like it or not...