}
}
// Generate the column identifier
IdentifierFactory idFactory = datastoreContainer.getStoreManager().getIdentifierFactory();
DatastoreIdentifier identifier = null;
if (colmd.getName() == null)
{
// No name specified, so generate the identifier from the field name
if (roleForField == JavaTypeMapping.MAPPING_FIELD)
{
identifier = idFactory.newIdentifier(IdentifierFactory.COLUMN, fmd.getName());
int i=0;
while (datastoreContainer.hasDatastoreField(identifier))
{
identifier = idFactory.newIdentifier(IdentifierFactory.COLUMN, fmd.getName() + "_" + i);
i++;
}
}
else if (roleForField == JavaTypeMapping.MAPPING_COLLECTION_ELEMENT)
{
// Join table collection element
identifier = ((RDBMSIdentifierFactory)idFactory).newJoinTableFieldIdentifier(fmd, null, null, true, FieldRole.ROLE_COLLECTION_ELEMENT);
}
else if (roleForField == JavaTypeMapping.MAPPING_ARRAY_ELEMENT)
{
// Join table array element
identifier = ((RDBMSIdentifierFactory)idFactory).newJoinTableFieldIdentifier(fmd, null, null, true, FieldRole.ROLE_ARRAY_ELEMENT);
}
else if (roleForField == JavaTypeMapping.MAPPING_MAP_KEY)
{
// Join table map key
identifier = ((RDBMSIdentifierFactory)idFactory).newJoinTableFieldIdentifier(fmd, null, null, true, FieldRole.ROLE_MAP_KEY);
}
else if (roleForField == JavaTypeMapping.MAPPING_MAP_VALUE)
{
// Join table map value
identifier = ((RDBMSIdentifierFactory)idFactory).newJoinTableFieldIdentifier(fmd, null, null, true, FieldRole.ROLE_MAP_VALUE);
}
colmd.setName(identifier.getIdentifier());
}
else
{
// User has specified a name, so try to keep this unmodified
identifier = idFactory.newDatastoreFieldIdentifier(colmds[datastoreFieldIndex].getName(),