Prepared statements cache should not take bound values into account
Description
See for context.
Currently the prepared statement cache (see here) uses PreparedRequest instances as its keys.
Such instances hold a SimpleStatement instance, which in turn, may contain bound values, and these are included in the DefaultSimpleStatement class' equals and hashCode methods.
The result is that two identical SimpleStatement instances differing only by their bound values will create two distinct keys in the cache, possibly causing the cache to grow uncontrollably.
But bound values are irrelevant in this context. We could explore a few ideas to improve this:
Just make it clear in the javadocs that the statement being prepared should be a template, that is, it should contain bind markers but no bound value.
Amend the constructor DefaultPrepareRequest(SimpleStatement) and explicitly remove the bound values:
See for context.
Currently the prepared statement cache (see here) uses
PreparedRequest
instances as its keys.Such instances hold a
SimpleStatement
instance, which in turn, may contain bound values, and these are included in theDefaultSimpleStatement
class'equals
andhashCode
methods.The result is that two identical
SimpleStatement
instances differing only by their bound values will create two distinct keys in the cache, possibly causing the cache to grow uncontrollably.But bound values are irrelevant in this context. We could explore a few ideas to improve this:
Just make it clear in the javadocs that the statement being prepared should be a template, that is, it should contain bind markers but no bound value.
Amend the constructor
DefaultPrepareRequest(SimpleStatement)
and explicitly remove the bound values: