Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Hibernate 7: an entity that is embedded and declares a hasMany is also bound standalone, with the holder's foreign key

オープン
#16,634 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/grails-core のほかの issue

apache/grails-core の issue をすべて見る

似ている issue

Databases の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。