[
https://issues.apache.org/jira/browse/OPENJPA-3034?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18138838#comment-18138838
]
ASF subversion and git services commented on OPENJPA-3034:
----------------------------------------------------------
Commit 1fad2c2b8cc2d5ccf319b8db549cad154a27a878 in openjpa's branch
refs/heads/OPENJPA-3034 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=1fad2c2b8 ]
[OPENJPA-3034] Order deletes by logical foreign keys
A schema not created by OpenJPA can have foreign key constraints the
mapping does not know of; a relation is then mapped to a logical foreign
key. Inserts are ordered by such keys since OPENJPA-2940, deletes were
not: removing the referenced entity before the referencing one in the
same flush issued the DELETEs in that order and violated the constraint
(TCK core.entitytest.persist.manyXone persistMX1Test2 and
cascadeall.manyXone cascadeAllMX1Test2 on Derby and SQL Server, whose
TCK DDL has no ON DELETE CASCADE).
RelationFieldStrategy.delete() and PrimaryRow now record a logical
foreign key of a deleted row to another deleted row, so that the
referencing row is deleted first, as for restrict and cascade keys.
Behaviour change: rows deleted in one flush that reference each other in
a cycle of nullable logical foreign keys are now ordered like rows with
restrict keys, i.e. the cycle is broken by one UPDATE setting a key to
null before the DELETEs. That is the statement a database enforcing the
keys needs, and what inserts of such a cycle issue since OPENJPA-2940;
deletes without a cycle issue no extra statement.
A logical key is ordered only on the chance that the database enforces
it. If such keys close a cycle that no nullable key can break, the
ConstraintUpdateManager now drops the ordering of a logical key instead
of throwing "no-nullable-fk"; that also covers inserts, which failed so
since OPENJPA-2940.
> Tests failing on several databases: sequence generator, timestamp, scalar
> expressions, mixed access
> ---------------------------------------------------------------------------------------------------
>
> Key: OPENJPA-3034
> URL: https://issues.apache.org/jira/browse/OPENJPA-3034
> Project: OpenJPA
> Issue Type: Sub-task
> Reporter: Richard Zowalla
> Priority: Major
>
> These tests fail on more than one database, which suggests a common cause:
> * {{sequenceGeneratorTest}}: Derby, MySQL, SQL Server. Check with
> OPENJPA-3014 (named sequence generator backed by a table where there are no
> sequences).
> * {{Client4.timestampFieldTest}}, {{timestampPropertyTest}}: MySQL, SQL
> Server (fractional seconds?)
> * {{scalarExpressionsTest}} ({{Client}} and {{Client1}}): Derby, SQL Server
> * {{Client2.mixedAccessTest}}, {{Client3.transientTest}},
> {{Client2.transientTest}}: Derby, SQL Server
> * {{cascadeAllMX1Test2}}, {{persistMX1Test2}}: Derby, SQL Server
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)