HHH-9302 - SQLGrammarException with @DiscriminatorColumn in an inheritance hierarchy
This commit is contained in:
parent
331383ccef
commit
9a9fb43ca5
|
@ -887,7 +887,6 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
return temp;
|
||||
}
|
||||
|
||||
|
||||
public String fromTableFragment(String alias) {
|
||||
return getTableName() + ' ' + alias;
|
||||
}
|
||||
|
@ -902,11 +901,24 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
select.setExtraSelectList( discriminatorFragment( name ), getDiscriminatorAlias() );
|
||||
}
|
||||
else {
|
||||
if ( getEntityMetamodel().getSuperclass() != null ) {
|
||||
name = generateTableAlias( name, getRootHierarchyClassTableIndex() );
|
||||
}
|
||||
select.addColumn( name, explicitDiscriminatorColumnName, discriminatorAlias );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getRootHierarchyClassTableIndex() {
|
||||
final String rootHierarchyClassTableName = naturalOrderTableNames[0];
|
||||
for ( int i = 0; i < subclassTableNameClosure.length; i++ ) {
|
||||
if ( subclassTableNameClosure[i].equals( rootHierarchyClassTableName ) ) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private CaseFragment discriminatorFragment(String alias) {
|
||||
CaseFragment cases = getFactory().getDialect().createCaseFragment();
|
||||
|
||||
|
|
Loading…
Reference in New Issue