protected String handleGetSqlType()
{
String value = null;
if (this.getSqlMappings() != null)
{
EntityAttribute identifier = null;
// we retrieve the column length from the first identifier of the primary key
// on the other side (since that should correspond to the foreign key).
if (this.getType() instanceof Entity)
{
final Entity type = (Entity)this.getType();
final Collection identifiers = type.getIdentifiers();
if (identifiers != null && !identifiers.isEmpty())
{
AttributeFacade attribute = (AttributeFacade)identifiers.iterator().next();
if (attribute instanceof EntityAttribute)
{
identifier = (EntityAttribute)attribute;
}
}
}
if (identifier != null && identifier.getType() != null)
{
String typeName = identifier.getType().getFullyQualifiedName(true);
value = this.getSqlMappings().getTo(typeName);
final String columnLength = identifier.getColumnLength();
if (StringUtils.isNotEmpty(columnLength))
{
value = EntityMetafacadeUtils.constructSqlTypeName(value, columnLength);
}
}