"order_inserts = true" causes FK Violation when inserting with a special case of Unidirectional Relations between 4 Entities

Description

In a particular case as described below, order-inserts = true causes FK Violation, while order-inserts = false does not:

  1. A entity refers to B entity in a OneToOne unidirectional relationship

  2. P entity refers to Q entity in a OneToOne unidirectional relationship

  3. A refers to a list of P entities in a OneToMany relationship, the ID of A is stored in P. P does not have an object reference to A in the class definition.

  4. All above entities have auto-generated/db-generated IDs

  5. When executing the following operations in order an FK violation occurs:

    • Persist A

    • Persist Q [Not required if cascadetype = persist on P->Q]

    • Set ID of A in P

    • Persist P [We only need 1 P to reproduce this issue]

    • Persist B

Due to fixes made in ActionQueue to solve issue HHH-13068, the order of the above insert statements is now flawed. While inserts should be in order: BAQP, inserts are instead sorted into order QPBA causing an FK Violation in P's FK reference to A.

This issue is reproducable on versions with the fix, that being versions 5.4.1 and 5.4.2. This issue does not occur in previous versions.

Attached testcase as

Environment

None

Attachments

Assignee

Gajendra Kumar

Reporter

Akarsh Jain

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure