[
https://issues.apache.org/jira/browse/OPENJPA-3043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18133144#comment-18133144
]
ASF subversion and git services commented on OPENJPA-3043:
----------------------------------------------------------
Commit 03efc3c4391d87f22f22cc9d9f78401b897b6e3d in openjpa's branch
refs/heads/OPENJPA-3039 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=03efc3c43 ]
[OPENJPA-3043] Record each occurrence of a parameter at its own position
> 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
> Priority: Major
>
> 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)