As a workaround, you can set a unique comment on each "interesting" call site so that you can control the viewing of the Oracle bind binding.
... query = session.createQuery("..."); ... query.setString("param1", "FOO"); query.setInteger("param2", param2Value); ... query.setComment("param1 = \"FOO\""); ...
Thus, the optimizer will see "FOO" with strong parsing time (as usual). In future calls, Oracle will look for an exact copy of SQL to reuse the execution plan. Since the comment makes the request unique, it will give you the same execution plan that was calculated using "FOO" , and not any other param1 value.
You have to be careful because the optimizer will also use the param2Value value to calculate the execution plan so that it can intervene. But I think that at least it’s worth a try.
source share