AbstractClassMetaData cmd) {
datastoreIDMapping = new OIDMapping();
datastoreIDMapping.initialize(storeMgr, cmd.getFullClassName());
// Create a ColumnMetaData in the container if none is defined
ColumnMetaData colmd;
if (columnMetaData == null) {
colmd = new ColumnMetaData();
} else {
colmd = columnMetaData;
}
if (colmd.getName() == null) {
// Provide default column naming if none is defined
if (refTable != null) {
colmd.setName(storeMgr.getIdentifierFactory()
.newDatastoreFieldIdentifier(refTable.getIdentifier().getIdentifierName(),
this.storeMgr.getNucleusContext().getTypeManager().isDefaultEmbeddedType(OID.class),
FieldRole.ROLE_OWNER).getIdentifierName());
} else {
colmd.setName(
storeMgr.getIdentifierFactory().newDatastoreFieldIdentifier(identifier.getIdentifierName(),
this.storeMgr.getNucleusContext().getTypeManager().isDefaultEmbeddedType(OID.class),
FieldRole.ROLE_NONE).getIdentifierName());
}
}
// Add the datastore identity column as the PK
DatastoreField idColumn = addDatastoreField(OID.class.getName(),
storeMgr.getIdentifierFactory().newIdentifier(IdentifierType.COLUMN, colmd.getName()),
datastoreIDMapping, colmd);
idColumn.setAsPrimaryKey();
// Set the identity column type based on the IdentityStrategy
String strategyName = cmd.getIdentityMetaData().getValueStrategy().toString();