// Loop through each id column in the reference table and add the same here
// applying the required names from the columnContainer
for (int j=0; j<mapping.getNumberOfDatastoreFields(); j++)
{
JavaTypeMapping m = masterMapping;
DatastoreField refColumn = mapping.getDataStoreMapping(j).getDatastoreField();
if (mapping instanceof PersistenceCapableMapping)
{
m = dba.getMapping(clr.classForName(refColumn.getMapping().getType()), storeMgr);
((PersistenceCapableMapping)masterMapping).addJavaTypeMapping(m);
}
ColumnMetaData userdefinedColumn = null;
if (userdefinedCols != null)
{
for (int k=0;k<userdefinedCols.length;k++)
{
if (refColumn.getIdentifier().toString().equals(userdefinedCols[k].getTarget()))
{
userdefinedColumn = userdefinedCols[k];
break;
}
}
if (userdefinedColumn == null && nextUserdefinedCol < userdefinedCols.length)
{
userdefinedColumn = userdefinedCols[nextUserdefinedCol++];
}
}
// Add this application identity column
DatastoreField idColumn = null;
if (userdefinedColumn != null)
{
// User has provided a name for this column
// Currently we only use the column namings from the users definition but we could easily
// take more of their details.
idColumn = addDatastoreField(refColumn.getStoredJavaType(),
storeMgr.getIdentifierFactory().newIdentifier(IdentifierFactory.COLUMN, userdefinedColumn.getName()),
m, refColumn.getMetaData());
}
else
{
// No name provided so take same as superclass
idColumn = addDatastoreField(refColumn.getStoredJavaType(), refColumn.getIdentifier(),
m, refColumn.getMetaData());
}
if (mapping != null && mapping.getDataStoreMapping(j).getDatastoreField().getMetaData() != null)
{
refColumn.copyConfigurationTo(idColumn);
}
idColumn.setAsPrimaryKey();
// Set the column type based on the field.getType()
getStoreManager().getMappingManager().createDatastoreMapping(m, storeMgr, idColumn,
refColumn.getMapping().getType());
}