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

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

Commit 6c18f9b689e8c2ea1146ca4a82bd4d61953d04df in openjpa's branch 
refs/heads/OPENJPA-3039 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=6c18f9b68 ]

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

A JPQL parameter compared with another parameter has no declared type, so
databases that require casts for comparisons, such as Derby, got two bare
parameter markers and rejected the statement. The comparison now casts such
parameters to the type of their bound values, and the prepared query cache
no longer caches these queries on such databases, because the casts depend
on the values of one execution. The check covers the filter, the having
clause and expressions such as a CASE in the select list, grouping and
ordering.

The positions of a parameter that occurs more than once in a statement with
other parameters in between, as in :a BETWEEN :b AND x, were recorded as the
first position only, so a cached query reused the old value for the later
occurrences.


> Derby: JPQL comparison of two parameters fails
> ----------------------------------------------
>
>                 Key: OPENJPA-3039
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-3039
>             Project: OpenJPA
>          Issue Type: Sub-task
>            Reporter: Richard Zowalla
>            Assignee: Richard Zowalla
>            Priority: Major
>
> On Derby, a JPQL comparison where both operands are parameters fails:
> {noformat}SELECT e FROM Entity e WHERE :a = :b
> 42X35: It is not allowed for both operands of '=' to be ? 
> parameters.{noformat}
> Derby has {{requiresCastForComparisons}}, but JPQL parameters have type 
> Object, so no cast is written. The criteria API case ({{cb.equal(param, 
> param)}} with typed parameters) is fixed in OPENJPA-3031; the JPQL case needs 
> the cast type from the bound value.



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

Reply via email to