Marco Belladelli ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=637b480... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYmUwYmIxOTky... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16355?atlOrigin=eyJpIjoiYmUwYm... ) HHH-16355 ( https://hibernate.atlassian.net/browse/HHH-16355?atlOrigin=eyJpIjoiYmUwYm... ) Map association with entity typed key breaks if mappedBy is specified ( https://hibernate.atlassian.net/browse/HHH-16355?atlOrigin=eyJpIjoiYmUwYm... )
Issue Type: Bug Affects Versions: 6.2.0.CR4 Assignee: Marco Belladelli ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=637b480... ) Created: 22/Mar/2023 08:39 AM Priority: Major Reporter: Marco Belladelli ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=637b480... )
In Hibernate 6.2 mapping a Map association with and entity typed key and mappedBy causes an error.
Here is an example mapping:
@Entity
@Table( name = "map_container_entity" )
public static class MapContainerEntity {
@Id
private Long id;
@OneToMany(mappedBy = "container" )
private Map<MapKeyEntity, MapValueEntity> map;
}
@Entity
@Table( name = "map_key_entity" )
public static class MapKeyEntity {
@Id
private Long id;
}
@Entity
@Table( name = "map_value_entity" )
public static class MapValueEntity {
@Id
private Long id;
@ManyToOne
private MapContainerEntity container;
}
And the error is:
Caused by: org.hibernate.MappingException: property [container] not found on entity [com.blazebit.persistence.testsuite.AliasBasedMapKeyDereferencingTest$MapKeyEntity]
at org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:570)
at org.hibernate.boot.model.internal.CollectionBinder.bindUnownedManyToManyInverseForeignKey(CollectionBinder.java:2657)
at org.hibernate.boot.model.internal.CollectionBinder.bindManyToManyInverseForeignKey(CollectionBinder.java:2619)
at org.hibernate.boot.model.internal.MapBinder.handleMapKey(MapBinder.java:184)
at org.hibernate.boot.model.internal.MapBinder.bindKeyFromAssociationTable(MapBinder.java:167)
at org.hibernate.boot.model.internal.MapBinder$1.secondPass(MapBinder.java:95)
at org.hibernate.boot.model.internal.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:45)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1850)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1807)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:324)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1380)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1451)
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:142)
at com.blazebit.persistence.testsuite.base.jpa.AbstractJpaPersistenceTest.createEntityManagerFactory(AbstractJpaPersistenceTest.java:848)
... 42 more
Caused by: org.hibernate.MappingException: property [container] not found on entity [com.blazebit.persistence.testsuite.AliasBasedMapKeyDereferencingTest$MapKeyEntity]
at org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:613)
at org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:566)
... 55 more
( https://hibernate.atlassian.net/browse/HHH-16355#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16355#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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100219- sha1:eb3f1fe )