[ 
https://issues.apache.org/jira/browse/OPENJPA-3043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18134690#comment-18134690
 ] 

ASF subversion and git services commented on OPENJPA-3043:
----------------------------------------------------------

Commit 9657b1ddf18599f3b7bf0aaf72ee84870aefff79 in openjpa's branch 
refs/heads/asciidoc from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=9657b1ddf ]

[OPENJPA-3039] Cast parameters compared with each other to the type of their 
values (#240)

* [OPENJPA-3043] Record each occurrence of a parameter at its own position

* [OPENJPA-3039] Cast parameters compared with each other to the type of their 
values

* [OPENJPA-3039] Add braces and use try-with-resources in the test

> 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
>             Fix For: 4.2.0
>
>
> 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