Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#16,634 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
18/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
groovy
Área
databases

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Groovy
Estrellas
2.9k
Forks
978
Merge medio
1 d 2 h
PR fusionados (30 d)
183

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/grails-core

Todos los issues de apache/grails-core

Issues similares

Más issues de Databases

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.