HHH-9302 - SQLGrammarException with @DiscriminatorColumn in an inheritance hierarchy

This commit is contained in:
Andrea Boriero 2015-11-25 10:33:32 +00:00
parent 331383ccef
commit 9a9fb43ca5
1 changed files with 13 additions and 1 deletions

View File

@ -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();