Set consistency level for DML annotations (i.e. @Insert(consistency=ALL))

8 views
Skip to first unread message

Ron Teller

unread,
Aug 24, 2023, 10:41:24 AM8/24/23
to DataStax Java Driver for Apache Cassandra User Mailing List
Hi,

I'm using the datastax @Insert annotation, and i would like to know if there is a possibility to set the consistency level? I did not see that the annotation supports this, but maybe there is another way to set the consistency level on a per query basis?
I know that i can set the consistency level of the CqlSession, however I would like to be able to set the consistency level per query.

Thanks,
Ron

Madhavan Sridharan

unread,
Aug 25, 2023, 9:30:43 AM8/25/23
to DataStax Java Driver for Apache Cassandra User Mailing List, Ron Teller
Hello there!

You could leverage statement attributes to achieve this. You've two options to define this either as a parameter or as an annotation. Checkout the documentation here on how to acheieve those.

Cheers!

Ron Teller

unread,
Aug 26, 2023, 2:16:05 PM8/26/23
to DataStax Java Driver for Apache Cassandra User Mailing List, Madhavan Sridharan, Ron Teller
Thank you very much Madhavan! This is exactly what I needed.
Reply all
Reply to author
Forward
0 new messages