HHH-14223 - Consider formulaTemplates in ID mapping for formula dereference

This commit is contained in:
Jan-Willem Gmelig Meyling 2020-09-28 12:16:53 +02:00 committed by Christian Beikov
parent ac34d72161
commit ad80d0bb41
1 changed files with 16 additions and 4 deletions

View File

@ -361,6 +361,7 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
columns,
columnReaders,
columnReaderTemplates,
formulaTemplates != null && formulaTemplates.length > 0 ? formulaTemplates : null,
factory
);
}
@ -373,6 +374,17 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
final String[] columnReaders,
final String[] columnReaderTemplates,
final Mapping factory) throws MappingException {
initIdentifierPropertyPaths(path, etype, columns, columnReaders, columnReaderTemplates, null, factory);
}
protected void initIdentifierPropertyPaths(
final String path,
final EntityType etype,
final String[] columns,
final String[] columnReaders,
final String[] columnReaderTemplates,
final String[] formulaTemplates,
final Mapping factory) throws MappingException {
Type idtype = etype.getIdentifierOrUniqueKeyType( factory );
String idPropName = etype.getIdentifierOrUniqueKeyPropertyName( factory );
@ -381,15 +393,15 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
if ( etype.isReferenceToPrimaryKey() ) {
if ( !hasNonIdentifierPropertyNamedId ) {
String idpath1 = extendPath( path, EntityPersister.ENTITY_ID );
addPropertyPath( idpath1, idtype, columns, columnReaders, columnReaderTemplates, null, factory );
initPropertyPaths( idpath1, idtype, columns, columnReaders, columnReaderTemplates, null, factory );
addPropertyPath( idpath1, idtype, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory );
initPropertyPaths( idpath1, idtype, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory );
}
}
if ( (! etype.isNullable() ) && idPropName != null ) {
String idpath2 = extendPath( path, idPropName );
addPropertyPath( idpath2, idtype, columns, columnReaders, columnReaderTemplates, null, factory );
initPropertyPaths( idpath2, idtype, columns, columnReaders, columnReaderTemplates, null, factory );
addPropertyPath( idpath2, idtype, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory );
initPropertyPaths( idpath2, idtype, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory );
}
}