Reputation: 1110
Maybe I overlooked it, but I can't find a way to specify consistency level in Datastax Object Mapping API for Java.
I understand that it is CQL3 based and in CQL, you can specify consistency by USING CONSISTENCY clause. But in Object Mapping API you wouldn't directly deal with the queries. So how would you specify the consistency when persisting or retrieving objects?
Upvotes: 1
Views: 908
Reputation: 1110
Took a look at the code in GitHub. There is indeed a way to set read and write consistency levels. You can specify the consistency levels using @Table annotation.
@Table (keyspace="XXX", name="riders", readConsistency="QUORUM", writeConsistency="QUORUM")
Upvotes: 1
Reputation: 3784
We also had same problem, because we used save()
method of Mapper
class. You can use saveQuery()
method which is creating Statement
out of your mapped class. Here is example:
final MappingManager mappingManager = new MappingManager(session);
Mapper<MyMappedClass> myMapper = mappingManager.mapper(MyMappedClass.class);
MyMappedClass myMappedInstance = new MyMappedClass(property1, propert2);
session.execute(myMapper.saveQuery(myMappedInstance).setConsistencyLevel(QUORUM));
Upvotes: 1
Reputation: 1931
There is a ton of documentation depending on what exactly are you doing. Please check the following pages:
Perhaps one of them will be helpful for your specific case.
Upvotes: 0