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 inheritanceStatePerClass
) ); ) );
foreignJoinColumns.setJoins( joins ); foreignJoinColumns.setJoins( joins );
if ( foreignJoinColumns.hasMappedBy() ) {
collection.setCollectionTable( associatedClass.getRecursiveProperty( foreignJoinColumns.getMappedBy() ).getValue().getTable() );
}
else {
collection.setCollectionTable( foreignJoinColumns.getTable() ); collection.setCollectionTable( foreignJoinColumns.getTable() );
}
if ( LOG.isDebugEnabled() ) { if ( LOG.isDebugEnabled() ) {
LOG.debugf( "Mapping collection: %s -> %s", collection.getRole(), collection.getCollectionTable().getName() ); LOG.debugf( "Mapping collection: %s -> %s", collection.getRole(), collection.getCollectionTable().getName() );
} }

View File

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