Mapping m = getRootMapping(referenced);
boolean tablePerSubclass = m != null && !m.getTablePerHierarchy();
if (referenced != null && !referenced.isRoot() && !tablePerSubclass) {
Mapping rootMapping = getRootMapping(referenced);
String discriminatorColumnName = RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME;
<BUG>if (rootMapping != null) {
final ColumnConfig discriminatorColumn = rootMapping.getDiscriminatorColumn();
</BUG>
if (discriminatorColumn != null) {
discriminatorColumnName = discriminatorColumn.getName();

Mapping m = getRootMapping(referenced);
boolean tablePerSubclass = m != null && !m.getTablePerHierarchy();
if (referenced != null && !referenced.isRoot() && !tablePerSubclass) {
Mapping rootMapping = getRootMapping(referenced);
String discriminatorColumnName = RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME;
if (rootMapping != null) {
DiscriminatorConfig discriminatorConfig = rootMapping.getDiscriminator();
if(discriminatorConfig != null) {
final ColumnConfig discriminatorColumn = discriminatorConfig.getColumn();
if (discriminatorColumn != null) {
discriminatorColumnName = discriminatorColumn.getName();
