Richard Zowalla created OPENJPA-3043:
----------------------------------------

             Summary: A parameter used twice with another parameter in between 
is bound at the wrong position from the query cache
                 Key: OPENJPA-3043
                 URL: https://issues.apache.org/jira/browse/OPENJPA-3043
             Project: OpenJPA
          Issue Type: Bug
            Reporter: Richard Zowalla
            Assignee: Richard Zowalla


When the same parameter appears twice in the SQL with another parameter in 
between, {{SQLBuffer}} records both occurrences at the position of the first 
one. For example
{code}
SELECT s FROM Entity s WHERE :a BETWEEN :b AND s.name
{code}
is rendered as {{? >= ? AND ? <= t0.NAME}}, and the user parameter positions of 
{{:a}} are 1 and 1 instead of 1 and 3. The first execution binds the values 
correctly, but when the SQL is reused from the prepared query cache, the third 
{{?}} keeps the value of the first execution, so the query returns wrong 
results without any error. This happens on every database.

Found while fixing OPENJPA-3039. Fixed in the same pull request: each 
occurrence of a parameter now gets its own position. {{TestSQLBuffer}} checks 
the positions directly.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to