Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#16,634 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
18/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
groovy
Lĩnh vực
databases

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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).

Ngôn ngữ chính
Groovy
Star
2.9k
Fork
976
Merge trung bình
21 giờ 14 phút
Pull request đã merge (30 ngày)
174

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/grails-core

Tất cả issue của apache/grails-core

Issue tương tự

Thêm issue về Databases

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.