HHH-15357 Fix access to mapped by map key
This commit is contained in:
parent
9cff075a89
commit
2b78f99ea8
|
@ -466,7 +466,7 @@ public class EntityCollectionPart
|
|||
// to preserve the cardinality. Also, the OneToManyTableGroup has no reference to the parent table group
|
||||
if ( !collectionDescriptor.isOneToMany() && targetKeyPropertyNames.contains( name ) ) {
|
||||
if ( fkTargetModelPart instanceof ToOneAttributeMapping ) {
|
||||
return fkTargetModelPart;
|
||||
return ( (ToOneAttributeMapping) fkTargetModelPart ).findSubPart( name, targetType );
|
||||
}
|
||||
final ModelPart keyPart = fkDescriptor.getKeyPart();
|
||||
if ( keyPart instanceof EmbeddableValuedModelPart && keyPart instanceof VirtualModelPart ) {
|
||||
|
|
|
@ -106,4 +106,19 @@ public class MapIssueTest {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-15357")
|
||||
public void testSelectMapKeyFk(SessionFactoryScope scope) {
|
||||
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector();
|
||||
statementInspector.clear();
|
||||
scope.inTransaction(
|
||||
s -> {
|
||||
s.createQuery( "select key(c).id from MapOwner as o left join o.contents c" ).list();
|
||||
statementInspector.assertExecutedCount( 1 );
|
||||
// Assert that only the collection table and element table are joined
|
||||
statementInspector.assertNumberOfJoins( 0, 2 );
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue