if (!isSerialisedValuePC())
{
if (isEmbeddedValuePC())
{
// Add any FKs for the fields of the (embedded) value
EmbeddedValuePCMapping embMapping = (EmbeddedValuePCMapping)valueMapping;
for (int i=0;i<embMapping.getNumberOfJavaTypeMappings();i++)
{
JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i);
AbstractMemberMetaData embFmd = embFieldMapping.getFieldMetaData();
if (this.storeMgr.getOMFContext().getTypeManager().isReferenceType(embFmd.getType()) &&
embFieldMapping instanceof ReferenceMapping)
{
// Field is a reference type, so add a FK to the table of the PC for each PC implementation
Collection fks = TableUtils.getForeignKeysForReferenceField(embFieldMapping, embFmd,
autoMode, storeMgr, clr);
foreignKeys.addAll(fks);
}
else if (storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(embFmd.getType(), clr) != null &&
embFieldMapping.getNumberOfDatastoreFields() > 0 &&
embFieldMapping instanceof PersistenceCapableMapping)
{
// Field is for a PC class with the FK at this side, so add a FK to the table of this PC
ForeignKey fk = TableUtils.getForeignKeyForPCField(embFieldMapping, embFmd,
autoMode, storeMgr, clr);
if (fk != null)
{
foreignKeys.add(fk);
}
}
}
}
else if (fmd.getMap().getValueClassMetaData() != null)
{
// FK from join table to value table
referencedTable = storeMgr.getDatastoreClass(fmd.getMap().getValueType(), clr);
if (referencedTable != null)
{
// Take <foreign-key> from <value>
ForeignKeyMetaData fkmd = null;
if (fmd.getValueMetaData() != null)
{
fkmd = fmd.getValueMetaData().getForeignKeyMetaData();
}
if (fkmd != null || autoMode)
{
ForeignKey fk = new ForeignKey(valueMapping, dba, referencedTable, true);
fk.setForMetaData(fkmd);
foreignKeys.add(fk);
}
}
}
}
if (!isSerialisedKeyPC())
{
if (isEmbeddedKeyPC())
{
// Add any FKs for the fields of the (embedded) key
EmbeddedKeyPCMapping embMapping = (EmbeddedKeyPCMapping)keyMapping;
for (int i=0;i<embMapping.getNumberOfJavaTypeMappings();i++)
{
JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i);
AbstractMemberMetaData embFmd = embFieldMapping.getFieldMetaData();
if (this.storeMgr.getOMFContext().getTypeManager().isReferenceType(embFmd.getType()) &&
embFieldMapping instanceof ReferenceMapping)
{
// Field is a reference type, so add a FK to the table of the PC for each PC implementation