问题
I'm using Datastax's lovely java driver for cassandra. I was trying to encapsulate all of my query strings into the built in accessors for mapping, but I require the ability to set the paging state for a query.
I see that this is possible with a normal Statement (SimpleStatement), but I haven't found the corresponding functionality for an Accessor. Does it exist, or do I have skip using Accessors for this functionality?
回答1:
I agree that this would be really nice to have.
One way to work with this for now would be to have your accessor return a Statement, i.e.:
@Query("SELECT * FROM ks.tbl WHERE id = ?")
Statement getAllById(@Param("id") UUID userId);
And then from there you call setPagingState
on the Statement
returned and execute it.
I agree that this isn't as nice as providing the paging state as a parameter to the Accessor, so I went ahead and opened up JAVA-1103.
回答2:
You can do it with Achilles:
manager
.select()
.allColumns_FromBaseTable()
.where()
.partitionKey_Eq(...)
...
.withPagingState(PagingState.fromString(...))
.getList();
来源:https://stackoverflow.com/questions/35679055/cassandra-datastax-driver-set-paging-state-on-accessor