in grails-datastore-gorm-hibernate/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinder.java [210:250]
protected void bindMapSecondPass(ToMany property, InFlightMetadataCollector mappings,
Map<?, ?> persistentClasses, org.hibernate.mapping.Map map, String sessionFactoryBeanName) {
bindCollectionSecondPass(property, mappings, persistentClasses, map, sessionFactoryBeanName);
SimpleValue value = new SimpleValue(metadataBuildingContext, map.getCollectionTable());
bindSimpleValue(getIndexColumnType(property, STRING_TYPE), value, true,
getIndexColumnName(property, sessionFactoryBeanName), mappings);
PropertyConfig pc = getPropertyConfig(property);
if (pc != null && pc.getIndexColumn() != null) {
bindColumnConfigToColumn(property, getColumnForSimpleValue(value), getSingleColumnConfig(pc.getIndexColumn()));
}
if (!value.isTypeSpecified()) {
throw new MappingException("map index element must specify a type: " + map.getRole());
}
map.setIndex(value);
if(!(property instanceof org.grails.datastore.mapping.model.types.OneToMany) && !(property instanceof ManyToMany)) {
SimpleValue elt = new SimpleValue(metadataBuildingContext, map.getCollectionTable());
map.setElement(elt);
String typeName = getTypeName(property,getPropertyConfig(property), getMapping(property.getOwner()));
if (typeName == null ) {
if(property instanceof Basic) {
Basic basic = (Basic) property;
typeName = basic.getComponentType().getName();
}
}
if(typeName == null || typeName.equals(Object.class.getName())) {
typeName = StandardBasicTypes.STRING.getName();
}
bindSimpleValue(typeName, elt, false, getMapElementName(property, sessionFactoryBeanName), mappings);
elt.setTypeName(typeName);
}
map.setInverse(false);
}