Hibernate 7: an entity that is embedded and declares a hasMany is also bound standalone, with the holder's foreign key
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 18/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- groovy
- 領域
- databases
調査の方向性
The bug sits in GormMappingConfigurationStrategy.getOrCreateEmbeddedEntity, where an embedded @Entity type returns the same PersistentEntity, and in TableForManyCalculator, which names the join table from the property owner. Start by reading how mappings.addTable is reached for both bindings and reproduce with the EmbeddedHolder/EmbeddedWithMany/EmbeddedMember classes from the issue. Done means the standalone collection gets its own table and key, or the component-only binding is the sole one that is created.
索引モデルが issue の本文から書いたものです。
説明
What happens
An entity that is embedded in another and also declares a hasMany is bound twice: once as a component of its holder and once as an entity of its own.
@Entity class EmbeddedHolder { EmbeddedWithMany embed; static embedded = ['embed'] }
@Entity class EmbeddedWithMany { static hasMany = [members: EmbeddedMember] }
@Entity class EmbeddedMember { String name }
GormMappingConfigurationStrategy.getOrCreateEmbeddedEntity returns the same PersistentEntity when the embedded type is itself an @Entity, so the standalone binding is always there, even if EmbeddedWithMany is never used on its own. Both bindings resolve the same join table name (TableForManyCalculator names it from the property's owner), and mappings.addTable hands back the same Table for both. The standalone collection's key therefore ends up with the holder's foreign key.
Why it matters
The session factory now builds (#16617 fixes the Collection key not bound failure), but the two bindings still share one join table and one key. Anything that relies on the standalone EmbeddedWithMany collection being independent of the holder's would be wrong.
Expected
An embedded entity's hasMany should be bound for the component only, or the two bindings should not share a table and key.
Found in
Review of #16617 (Hibernate 7, 8.0.x).
- 主要言語
- Groovy
- スター
- 2.9k
- フォーク
- 976
- 平均マージ
- 21時間 14分
- マージ済み PR(30日)
- 174
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/grails-core のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
apache/grails-core#16635 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/grails-core#16289 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/grails-core#15764 ·
メンテナーはふだん 1 日以内に返信
-
Update documentation for Java 25対応中かも @ruthst00 が 9 日前に担当しました。 オープンrelates-to: documentation weekly-action-item
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
apache/grails-core#15725 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
apache/grails-core#16633 ·
メンテナーはふだん 1 日以内に返信
apache/grails-core の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
mariadb-operator/mariadb-operator#1962 ·
メンテナーはふだん 1 日以内に返信
-
bug difficulty: easy
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
MetroLogic/fluxapay_contract#1022 ·
メンテナーはふだん 1 日以内に返信
-
bug jdbc-v2
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
ClickHouse/clickhouse-java#3214 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
database high-priority security
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
bridgelet-org/bridgelet-sdk#879 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信