Hi There,

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. This hack works but
we are too comfortable with this. Is there a better way to achieve this?

More details in the following link with code:
https://stackoverflow.com/questions/60198114/how-to-get-two-preparedstatement-objects-for-the-same-query-string

Let me know if you have any questions.

Thanks,
Deepak

Reply via email to