{
// Backwards compatibility only. Creates discriminator in all subclass tables even though not needed
// TODO Remove this in the future
if (dismd.getStrategy() == DiscriminatorStrategy.CLASS_NAME)
{
discriminatorMapping = new DiscriminatorStringMapping(dba, this,
mapMgr.getMapping(String.class));
}
else if (dismd.getStrategy() == DiscriminatorStrategy.VALUE_MAP)
{
ColumnMetaData disColmd = dismd.getColumnMetaData();
if (disColmd != null && disColmd.getJdbcType() != null)
{
if (disColmd.getJdbcType().equalsIgnoreCase("INTEGER") ||
disColmd.getJdbcType().equalsIgnoreCase("BIGINT") ||
disColmd.getJdbcType().equalsIgnoreCase("NUMERIC"))
{
discriminatorMapping = new DiscriminatorLongMapping(dba, this,
mapMgr.getMapping(Long.class));
}
else
{
discriminatorMapping = new DiscriminatorStringMapping(dba, this,
mapMgr.getMapping(String.class));
}
}
else
{
discriminatorMapping = new DiscriminatorStringMapping(dba, this,
mapMgr.getMapping(String.class));
}
}
}
else
{
// Create discriminator column only in top most table that needs it
ClassTable tableWithDiscrim = getTableWithDiscriminator();
if (tableWithDiscrim == this)
{
// No superclass with a discriminator so add it in this table
if (dismd.getStrategy() == DiscriminatorStrategy.CLASS_NAME)
{
discriminatorMapping = new DiscriminatorStringMapping(dba, this,
mapMgr.getMapping(String.class));
}
else if (dismd.getStrategy() == DiscriminatorStrategy.VALUE_MAP)
{
ColumnMetaData disColmd = dismd.getColumnMetaData();
if (disColmd != null && disColmd.getJdbcType() != null)
{
if (disColmd.getJdbcType().equalsIgnoreCase("INTEGER") ||
disColmd.getJdbcType().equalsIgnoreCase("BIGINT") ||
disColmd.getJdbcType().equalsIgnoreCase("NUMERIC"))
{
discriminatorMapping = new DiscriminatorLongMapping(dba, this,
mapMgr.getMapping(Long.class));
}
else
{
discriminatorMapping = new DiscriminatorStringMapping(dba, this,
mapMgr.getMapping(String.class));
}
}
else
{
discriminatorMapping = new DiscriminatorStringMapping(dba, this,
mapMgr.getMapping(String.class));
}
}
}
}