How to get two PreparedStatement objects for the same query string
We have a use case where we need to have two separate PreparedStatement objects (one with RetryPolicy and the other without any retry policy) for the same query string.
And when we try to create two separate PreparedStatements, we see only one PreparedStatement getting retained (the previous PreparedStatement gets overridden by the last PreparedStatement). We looked at the code implementation and see that method
Cluster.addPrepared is looking at some kind of MD5 hash for the query and it overrides the old PreparedStatement with the new PreparedStatement.
To overcome this behavior we are creating two separate queries (the second query has an extra space at the end compared to first query) to distinguish them so that we end up getting two prepared statements.
Eg: First query:
select * from test, Second query:
"select * from test "
Is there a better way of creating two separate PreparedStatements for the same query string as our use case demands it? To us it looks error prone.
We are using cassandra-drive-core-3.1.0-shaded.jar