Fix issue with AbstractEntityPersister and the creation of the RootTableGroup

This commit is contained in:
Andrea Boriero 2020-01-30 17:34:30 +00:00
parent 16d81eb4bf
commit 8c16e7cfe9
4 changed files with 20 additions and 10 deletions

View File

@ -387,6 +387,8 @@ public abstract class AbstractEntityPersister
public abstract String getSubclassTableName(int j);
protected abstract String[] getSubclassTableNames();
protected abstract String[] getSubclassTableKeyColumns(int j);
protected abstract boolean isClassOrSuperclassTable(int j);
@ -1267,7 +1269,7 @@ public abstract class AbstractEntityPersister
lockMode,
primaryTableReference,
sqlAliasBase,
(tableExpression) -> ArrayHelper.contains( rootTableKeyColumnNames, tableExpression ),
(tableExpression) -> ArrayHelper.contains( getSubclassTableNames(), tableExpression ),
(tableExpression, tableGroup) -> {
for ( int i = 0; i < getSubclassTableSpan(); i++ ) {
final String subclassTableName = getSubclassTableName( i );

View File

@ -1057,6 +1057,11 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
return subclassTableNameClosure[j];
}
@Override
protected String[] getSubclassTableNames() {
return subclassTableNameClosure;
}
public int getSubclassTableSpan() {
return subclassTableNameClosure.length;
}

View File

@ -809,6 +809,11 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
return subclassTableNameClosure[j];
}
@Override
protected String[] getSubclassTableNames() {
return subclassTableNameClosure;
}
public int getSubclassTableSpan() {
return subclassTableNameClosure.length;
}

View File

@ -67,7 +67,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
private final String subquery;
private final String tableName;
//private final String rootTableName;
private final String[] subclassClosure;
private final String[] subclassTableNames;
private final String[] spaces;
private final String[] subclassSpaces;
private final Object discriminatorValue;
@ -101,7 +101,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
// TABLE
tableName = determineTableName( persistentClass.getTable(), jdbcEnvironment );
subclassTableNames = new String[]{tableName};
//Custom SQL
String sql;
@ -146,8 +146,6 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
// PROPERTIES
int subclassSpan = persistentClass.getSubclassSpan() + 1;
subclassClosure = new String[subclassSpan];
subclassClosure[0] = getEntityName();
// SUBCLASSES
subclassByDiscriminatorValue.put(
@ -159,7 +157,6 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
int k = 1;
while ( iter.hasNext() ) {
Subclass sc = (Subclass) iter.next();
subclassClosure[k++] = sc.getEntityName();
subclassByDiscriminatorValue.put( sc.getSubclassId(), sc.getEntityName() );
}
}
@ -280,10 +277,6 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
return discriminatorSQLValue;
}
public String[] getSubclassClosure() {
return subclassClosure;
}
@Override
public String getSubclassForDiscriminatorValue(Object value) {
return (String) subclassByDiscriminatorValue.get( value );
@ -519,6 +512,11 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
return tableName;
}
@Override
protected String[] getSubclassTableNames(){
return subclassTableNames;
}
@Override
public int getSubclassTableSpan() {
return 1;