debugMapping(keyMapping);
}
if (valueKeyFieldName != null && isEmbeddedKeyPC())
{
// Key (PC) is embedded and value is a field of the key
EmbeddedKeyPCMapping embMapping = (EmbeddedKeyPCMapping)keyMapping;
valueMapping = embMapping.getJavaTypeMapping(valueKeyFieldName);
}
}
else
{
// Key = PC
ColumnMetaData[] keyColmd = null;
KeyMetaData keymd = mmd.getKeyMetaData();
if (keymd != null && keymd.getColumnMetaData() != null && keymd.getColumnMetaData().length > 0)
{
// Column mappings defined at this side (1-N, M-N)
keyColmd = keymd.getColumnMetaData();
}
keyMapping = ColumnCreator.createColumnsForJoinTables(keyCls, mmd, keyColmd, storeMgr, this,
false, false, FieldRole.ROLE_MAP_KEY, clr);
if (mmd.getContainer().allowNulls() == Boolean.TRUE)
{
// Make all key col(s) nullable so we can store null elements
for (int i=0;i<keyMapping.getNumberOfDatastoreMappings();i++)
{
Column elementCol = (Column)keyMapping.getDatastoreMapping(i).getDatastoreField();
elementCol.setNullable();
}
}
if (NucleusLogger.DATASTORE.isDebugEnabled())
{
debugMapping(keyMapping);
}
}
// Add value mapping
boolean valuePC = (mmd.hasMap() && mmd.getMap().valueIsPersistent());
Class valueCls = clr.classForName(mapmd.getValueType());
if (valueKeyFieldName != null && isEmbeddedKeyPC())
{
// Added in key code
}
else if (isSerialisedValue() || isEmbeddedValuePC() || (isEmbeddedValue() && !valuePC) ||
ClassUtils.isReferenceType(valueCls))
{
// Value = PC(embedded), PC(serialised), Non-PC(serialised), Non-PC(embedded), Reference
valueMapping = storeMgr.getMappingManager().getMapping(this, mmd, clr, FieldRole.ROLE_MAP_VALUE);
if (mmd.getContainer().allowNulls() == Boolean.TRUE)
{
// Make all value col(s) nullable so we can store null elements
for (int i=0;i<valueMapping.getNumberOfDatastoreMappings();i++)
{
Column elementCol = (Column)valueMapping.getDatastoreMapping(i).getDatastoreField();
elementCol.setNullable();
}
}
if (NucleusLogger.DATASTORE.isDebugEnabled())
{
debugMapping(valueMapping);
}
if (keyValueFieldName != null && isEmbeddedValuePC())
{
// Value (PC) is embedded and key is a field of the value
EmbeddedValuePCMapping embMapping = (EmbeddedValuePCMapping)valueMapping;
keyMapping = embMapping.getJavaTypeMapping(keyValueFieldName);
}
}
else
{
// Value = PC