-
Notifications
You must be signed in to change notification settings - Fork 364
Open
Labels
type: bugA general bugA general bug
Description
Issue
If child object has an id column which named different with parent's id,
an invalid DELETE query created and failed to execute the test JdbcRepositoryWithCollectionsChainHsqlIntegrationTests#deleteByName
.
(in 3.5.x, 4.0.0-M versions)
I reproduced in commit chanhyeong@7cca9ee, and it creates an error message below.
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [DELETE FROM "GRAND_CHILD_ELEMENT" WHERE "GRAND_CHILD_ELEMENT"."CHILD_ELEMENT" IN (SELECT "CHILD_ELEMENT"."ID" FROM "CHILD_ELEMENT" WHERE "CHILD_ELEMENT"."DUMMY_ENTITY" IN (SELECT "DUMMY_ENTITY"."ID" FROM "DUMMY_ENTITY" WHERE "DUMMY_ENTITY"."NAME" = ?))]
Here is the query in message to read easily.
DELETE FROM
"GRAND_CHILD_ELEMENT"
WHERE
"GRAND_CHILD_ELEMENT"."CHILD_ELEMENT" IN (
SELECT
"CHILD_ELEMENT"."ID"
FROM
"CHILD_ELEMENT"
WHERE
"CHILD_ELEMENT"."DUMMY_ENTITY" IN (
SELECT
"DUMMY_ENTITY"."ID"
FROM
"DUMMY_ENTITY"
WHERE
"DUMMY_ENTITY"."NAME" = ?
)
)
Expected
It should select "CHILD_ELEMENT"."CHILD_ID"
in first IN
statement, instead of "CHILD_ELEMENT"."ID"
.
Resolution
If JdbcDeleteQueryCreator#deleteRelation
takes the id column of current path on SELECT phrase, this issue will be fixed.
- 3.5.x: chanhyeong@d94a1a9
- 4.0.0-M: chanhyeong@e28a250
If I misunderstood the operation, please let me know.
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug