Yoann Rodière (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNmE1MzQyZTUx...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-15604?atlOrigin=eyJpIjoiNmE1Mz...
) HHH-15604 (
https://hibernate.atlassian.net/browse/HHH-15604?atlOrigin=eyJpIjoiNmE1Mz...
) Identically-named association in entity root and elementcollection of embeddables leads
to assertion error (
https://hibernate.atlassian.net/browse/HHH-15604?atlOrigin=eyJpIjoiNmE1Mz...
)
Issue Type: Bug Assignee: Unassigned Components: hibernate-core Created: 14/Oct/2022 06:09
AM Fix Versions: 6.2.0 Priority: Major Reporter: Yoann Rodière (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Affects Hibernate ORM 6.2, probably also 6.1 and 6.0, but definitely not 5.6.
This model:
@Entity(name = "entityA")
public static class EntityA {
@Id
private Integer id;
@OneToOne(mappedBy = "identicallyNamedAssociation", fetch = FetchType.LAZY)
private EntityB b;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public EntityB getB() {
return b;
}
public void setB(EntityB b) {
this.b = b;
}
}
@Entity(name = "entityB")
public static class EntityB {
@Id
private Integer id;
@OneToOne
@JoinColumn(name = "entityA_id")
private EntityA identicallyNamedAssociation;
@ElementCollection
@Embedded
@OrderColumn(name = "idx")
@CollectionTable(name = "elemcollect")
private List<EmbeddableB> elementCollection = new ArrayList<>();
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public EntityA getIdenticallyNamedAssociation() {
return identicallyNamedAssociation;
}
public void setIdenticallyNamedAssociation(EntityA a) {
this.identicallyNamedAssociation = a;
}
public List<EmbeddableB> getElementCollection() {
return elementCollection;
}
}
@Embeddable
public static class EmbeddableB {
@OneToOne
@JoinColumn(name = "emb_entityA_id")
private EntityA identicallyNamedAssociation;
public EntityA getIdenticallyNamedAssociation() {
return identicallyNamedAssociation;
}
public void setIdenticallyNamedAssociation(EntityA a) {
this.identicallyNamedAssociation = a;
}
}
Leads to this stack trace:
java.lang.AssertionError
at
org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping.withRegisteredAssociationKeys(ToOneAttributeMapping.java:1492)
at
org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping.generateFetch(ToOneAttributeMapping.java:1232)
at
org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping.generateFetch(ToOneAttributeMapping.java:106)
at
org.hibernate.sql.results.graph.FetchParent.generateFetchableFetch(FetchParent.java:105)
at
org.hibernate.loader.ast.internal.LoaderSelectBuilder.lambda$createFetchableBiConsumer$9(LoaderSelectBuilder.java:842)
at
org.hibernate.loader.ast.internal.LoaderSelectBuilder.lambda$visitFetches$8(LoaderSelectBuilder.java:681)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at
org.hibernate.metamodel.mapping.internal.EmbeddableMappingTypeImpl.visitAttributeMappings(EmbeddableMappingTypeImpl.java:726)
at
org.hibernate.metamodel.mapping.internal.EmbeddableMappingTypeImpl.visitSubParts(EmbeddableMappingTypeImpl.java:736)
at
org.hibernate.metamodel.mapping.internal.EmbeddedCollectionPart.visitSubParts(EmbeddedCollectionPart.java:286)
at
org.hibernate.sql.results.graph.FetchableContainer.visitFetchables(FetchableContainer.java:35)
at
org.hibernate.loader.ast.internal.LoaderSelectBuilder.visitFetches(LoaderSelectBuilder.java:680)
at
org.hibernate.loader.ast.internal.LoaderSqlAstCreationState.visitFetches(LoaderSqlAstCreationState.java:118)
at
org.hibernate.sql.results.graph.AbstractFetchParent.afterInitialize(AbstractFetchParent.java:32)
at
org.hibernate.sql.results.graph.embeddable.internal.EmbeddableFetchImpl.<init>(EmbeddableFetchImpl.java:75)
at
org.hibernate.metamodel.mapping.internal.EmbeddedCollectionPart.generateFetch(EmbeddedCollectionPart.java:162)
at
org.hibernate.sql.results.graph.FetchParent.generateFetchableFetch(FetchParent.java:105)
at
org.hibernate.collection.spi.InitializerProducerBuilder.createListInitializerProducer(InitializerProducerBuilder.java:153)
at
org.hibernate.collection.spi.InitializerProducerBuilder.createCollectionTypeWrapperInitializerProducer(InitializerProducerBuilder.java:255)
at
org.hibernate.collection.internal.CustomCollectionTypeSemantics.createInitializerProducer(CustomCollectionTypeSemantics.java:79)
at
org.hibernate.collection.spi.CollectionSemantics.createInitializerProducer(CollectionSemantics.java:94)
at
org.hibernate.sql.results.graph.collection.internal.CollectionDomainResult.<init>(CollectionDomainResult.java:64)
at
org.hibernate.metamodel.mapping.internal.PluralAttributeMappingImpl.createDomainResult(PluralAttributeMappingImpl.java:370)
at
org.hibernate.loader.ast.internal.LoaderSelectBuilder.generateSelect(LoaderSelectBuilder.java:450)
at
org.hibernate.loader.ast.internal.LoaderSelectBuilder.createSelect(LoaderSelectBuilder.java:177)
at
org.hibernate.loader.ast.internal.CollectionLoaderSingleKey.<init>(CollectionLoaderSingleKey.java:61)
at
org.hibernate.persister.collection.AbstractCollectionPersister.createCollectionLoader(AbstractCollectionPersister.java:869)
at
org.hibernate.persister.collection.AbstractCollectionPersister.postInstantiate(AbstractCollectionPersister.java:750)
at
java.base/java.util.concurrent.ConcurrentHashMap$ValuesView.forEach(ConcurrentHashMap.java:4772)
at
org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.finishInitialization(MappingMetamodelImpl.java:240)
at
org.hibernate.metamodel.internal.RuntimeMetamodelsImpl.finishInitialization(RuntimeMetamodelsImpl.java:60)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309)
at
org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:415)
at
org.hibernate.testing.orm.junit.SessionFactoryExtension.lambda$createSessionFactoryScope$0(SessionFactoryExtension.java:151)
(
https://hibernate.atlassian.net/browse/HHH-15604#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15604#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100208- sha1:492d0ce )