HHH-16860 Fix joined inheritance associations on root class

This commit is contained in:
Marco Belladelli 2023-07-05 16:38:35 +02:00 committed by Steve Ebersole
parent 79fe21648c
commit 382037ec91
2 changed files with 10 additions and 2 deletions

View File

@ -1658,7 +1658,12 @@ protected void bindOneToManySecondPass(Map<String, PersistentClass> persistentCl
inheritanceStatePerClass
) );
foreignJoinColumns.setJoins( joins );
collection.setCollectionTable( foreignJoinColumns.getTable() );
if ( foreignJoinColumns.hasMappedBy() ) {
collection.setCollectionTable( associatedClass.getRecursiveProperty( foreignJoinColumns.getMappedBy() ).getValue().getTable() );
}
else {
collection.setCollectionTable( foreignJoinColumns.getTable() );
}
if ( LOG.isDebugEnabled() ) {
LOG.debugf( "Mapping collection: %s -> %s", collection.getRole(), collection.getCollectionTable().getName() );
}

View File

@ -323,7 +323,7 @@ public TableGroup createTableGroupInternal(
creationState
);
return new StandardTableGroup(
final TableGroup tableGroup = new StandardTableGroup(
canUseInnerJoins,
navigablePath,
this,
@ -341,6 +341,9 @@ public TableGroup createTableGroupInternal(
),
creationContext.getSessionFactory()
);
// Make sure the association key's table is resolved in the table group
tableGroup.getTableReference( null, resolveFetchAssociationKey().getTable(), true );
return tableGroup;
}