Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.0
-
Fix Version/s: 1.0.1
-
Component/s: JDO queries
-
Labels:None
-
Number of attachments :
Description
While upgrading from Castor 0.9.3 to 1.0 I discovered that pass-through SQL queries containing repeated numbered parameters suddenly ceased to work. Here is a very basic example of such a query:
SELECT * FROM foo WHERE foo.field1 = $1 AND foo.field2 = $1
Looking at the debugging info I was able to establish that the second parameter was interpreted so as it was given as $2.
A couple of hours later I found the problem in org.exolab.castor.jdo.engine.OQLQueryImpl.createCall(). The method parses the provided SQL query, replaces all the dollars with question marks and throws away all the parameter numbers.
The correct behaviour would be to simply replace $n with ?n, which is then correctly interpreted by org.exolab.castor.util.SqlBindParser responsible for setting the actual parameter values.
The attached patch fixes the problem and additionally corrects a minor glitch a couple of lines below ![]()
Thanks, Pawel. We'll be having a look at your patch once we've got our project infrastructure back, incl. e.g. SVN repo, etc.