From 556285b735fe4ec93e5ca3175fc6b6e4f258e7d2 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Mon, 7 Oct 2024 19:49:57 +0200 Subject: [PATCH] HHH-18703 Use natural order table numbers for subclass column closure --- .../entity/JoinedSubclassEntityPersister.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java index a5c17ca8a9..3326a87656 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java @@ -127,7 +127,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister { // the closure of all columns used by the entire hierarchy including // subclasses and superclasses of this class - private final int[] subclassColumnTableNumberClosure; + private final int[] subclassColumnNaturalOrderTableNumberClosure; // private final int[] subclassFormulaTableNumberClosure; private final String[] subclassColumnClosure; @@ -470,11 +470,12 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister { final String tableName = property.getValue().getTable(). getQualifiedName( creationContext.getSqlStringGenerationContext() ); final Integer tableNumber = getTableId( tableName, subclassTableNameClosure ); + final Integer naturalTableNumber = getTableId( tableName, naturalOrderSubclassTableNameClosure ); propTableNumbers.add( tableNumber ); for ( Selectable selectable : property.getSelectables() ) { if ( !selectable.isFormula() ) { - columnTableNumbers.add( tableNumber ); + columnTableNumbers.add( naturalTableNumber ); Column column = (Column) selectable; columns.add( column.getQuotedName( dialect ) ); } @@ -484,7 +485,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister { } } - subclassColumnTableNumberClosure = toIntArray( columnTableNumbers ); + subclassColumnNaturalOrderTableNumberClosure = toIntArray( columnTableNumbers ); subclassPropertyTableNumberClosure = toIntArray( propTableNumbers ); // subclassFormulaTableNumberClosure = ArrayHelper.toIntArray( formulaTableNumbers ); subclassColumnClosure = toStringArray( columns ); @@ -1069,12 +1070,12 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister { && subclassColumnClosure[i].endsWith( "\"" ); if ( quoted ) { if ( subclassColumnClosure[i].equals( columnName ) ) { - return subclassColumnTableNumberClosure[i]; + return subclassColumnNaturalOrderTableNumberClosure[i]; } } else { if ( subclassColumnClosure[i].equalsIgnoreCase( columnName ) ) { - return subclassColumnTableNumberClosure[i]; + return subclassColumnNaturalOrderTableNumberClosure[i]; } } }