(注:このブログはもう更新していません)この日記は私的なものであり所属会社の見解とは無関係です。 GitHub: takahashikzn

[クラウド帳票エンジンDocurain]

Memo: EclipseLinkが関連エンティティをUPDATE/DELETEする順序はID順

「同一オブジェクトの1-Nの関連先エンティティを同時更新した時、デッドロックは発生しないのか?」という点が急に気になったので調べたときのメモ。

EclipseLinkの場合、エンティティのUPDATE順序はデフォルトで「ID順」 で、その他に「オブジェクトの変更された順」「無指定」も指定できます。

Javadocによると、

The "eclipselink.persistence-context.commit-order" property defines the ordering of updates and deletes of a set of the same entity type during a commit or flush operation.

"eclipselink.persistence-context.commit-order"プロパティは、commitおよびflush時において、同一型のエンティティのうちでUPDATEとDELETEの順序を規定する。


The commit order of entities is defined by their foreign key constraints, and then sorted alphabetically.

コミット時の更新順序は、外部キー制約により決定される。そしてエンティティはアルファベット順(訳注: 属性名またはエンティティ名のアルファベット順という意味?)でソートされる。


By default the commit of a set of the same entity type is ordered by its Id.

デフォルトでは、同一型のエンティティはID順で処理される。

とのこと。