Date
1 - 10 of 10
Delete query with IN clause having a single parameter
prashant.mr@...
In our project, a Delete query is showing an error when used with IN clause having a single parameter.
I've forked the test-jpa project [1] and updated the SimpleTest.java [2] to recreate this issue. The following query shows an error message: "Exception thrown when executing query : DELETE FROM PERSON A0 WHERE A0."NAME" = ? AND A0.ID =" But the following two similar queries work: DELETE FROM Person AS p where p.id IN (?1) AND p.name = ?2 DELETE FROM Person AS p where p.name = ?1 AND p.id IN (?2, ?3) I'd really appreciate any help to resolve this issue. Thanks. [1] https://github.com/prashantbhat/test-jpa [2] https://github.com/prashantbhat/test-jpa/blob/master/src/test/java/org/datanucleus/test/SimpleTest.java |
|||
|
|||
Care to post the actual exception + stack trace because it will tell you the problem. The log also tells you what the query is compiled to ... generic query, as well as the SQL.
|
|||
|
|||
prashant.mr@...
Sorry, when trying to edit, I deleted the last message posted here.
I'm attaching the complete log file with only single run, this time. Thanks, |
|||
|
|||
Generic compilation looks fine to me so suggest that you get the code for datanucleus-rdbms and start debugging around QueryToSQLMapper.processInExpression
https://github.com/datanucleus/datanucleus-rdbms/blob/master/src/main/java/org/datanucleus/store/rdbms/query/QueryToSQLMapper.java |
|||
|
|||
prashant.mr@...
Thanks for pointing to the code for debugging. I'm quite new to the internals of DataNucleus, so it may take some time.
|
|||
|
|||
prashant.mr@...
After some debugging, following is my analysis and a possible solution: |
|||
|
|||
Updating DyadicExpression (or even updating general code in datanucleus-core) is not an option because it may affect other databases handling (and then would mean having to re-run ALL tests on all databases), and also because if the right expression is a LIST parameter then it is wrong.
|
|||
|
|||
prashant.mr@...
Ok, I've now reworked on this, by making changes only to QueryToSQLMapper#processInExpression.
toggle quoted message
Show quoted text
As in the processEqExpression, replacing the parameterLiteral with the left/right JavaTypeMapping is working for queries, listed in my original SimpleTest.java I've included the diff here below for your review. diff --git a/src/main/java/org/datanucleus/store/rdbms/query/QueryToSQLMapper.java b/src/main/java/org/datanucleus/store/rdbms/query/QueryToSQLMapper.java |
|||
|
|||
I've added a variant of that to GitHub master that caters for single-valued parameter at left hand side or right hand side.
|
|||
|
|||
prashant.mr@...
Thanks a lot
|
|||
|