in grails-datastore-gorm-hibernate/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinder.java [2091:2147]
protected void bindEnumType(PersistentProperty property, Class<?> propertyType, SimpleValue simpleValue, String columnName) {
PropertyConfig pc = getPropertyConfig(property);
final PersistentEntity owner = property.getOwner();
String typeName = getTypeName(property, getPropertyConfig(property), getMapping(owner));
if (typeName == null) {
Properties enumProperties = new Properties();
enumProperties.put(ENUM_CLASS_PROP, propertyType.getName());
String enumType = pc == null ? DEFAULT_ENUM_TYPE : pc.getEnumType();
boolean isDefaultEnumType = enumType.equals(DEFAULT_ENUM_TYPE);
simpleValue.setTypeName(ENUM_TYPE_CLASS);
if (isDefaultEnumType || "string".equalsIgnoreCase(enumType)) {
enumProperties.put(EnumType.TYPE, String.valueOf(Types.VARCHAR));
enumProperties.put(EnumType.NAMED, Boolean.TRUE.toString());
}
else if("identity".equals(enumType)) {
simpleValue.setTypeName(IdentityEnumType.class.getName());
}
else if (!"ordinal".equalsIgnoreCase(enumType)) {
simpleValue.setTypeName(enumType);
}
simpleValue.setTypeParameters(enumProperties);
}
else {
simpleValue.setTypeName(typeName);
}
Table t = simpleValue.getTable();
Column column = new Column();
if (owner.isRoot()) {
column.setNullable(property.isNullable());
} else {
Mapping mapping = getMapping(owner);
if (mapping == null || mapping.getTablePerHierarchy()) {
if (LOG.isDebugEnabled()) {
LOG.debug("[GrailsDomainBinder] Sub class property [" + property.getName() +
"] for column name [" + column.getName() + "] set to nullable");
}
column.setNullable(true);
} else {
column.setNullable(property.isNullable());
}
}
column.setValue(simpleValue);
column.setName(columnName);
if (t != null) t.addColumn(column);
simpleValue.addColumn(column);
PropertyConfig propertyConfig = getPropertyConfig(property);
if (propertyConfig != null && !propertyConfig.getColumns().isEmpty()) {
bindIndex(columnName, column, propertyConfig.getColumns().get(0), t);
bindColumnConfigToColumn(property, column, propertyConfig.getColumns().get(0));
}
}