**/
public void initialize(ClassLoaderResolver clr)
{
assertIsUninitialized();
MapMetaData mmd = fmd.getMap();
if (mmd == null)
{
throw new JPOXUserException(LOCALISER.msg("057017",fmd));
}
PrimaryKeyMetaData pkmd = (fmd.getJoinMetaData() != null ? fmd.getJoinMetaData().getPrimaryKeyMetaData() : null);
boolean pkColsSpecified = (pkmd != null && pkmd.getColumnMetaData() != null);
boolean pkRequired = requiresPrimaryKey();
// Add owner mapping
ColumnMetaData[] ownerColmd = null;
if (fmd.getJoinMetaData() != null &&
fmd.getJoinMetaData().getColumnMetaData() != null &&
fmd.getJoinMetaData().getColumnMetaData().length > 0)
{
// Column mappings defined at this side (1-N, M-N)
// When specified at this side they use the <join> tag
ownerColmd = fmd.getJoinMetaData().getColumnMetaData();
}
ownerMapping = ColumnCreator.createColumnsForJoinTables(clr.classForName(ownerType), fmd, ownerColmd,
storeMgr, this, pkRequired, false, false, false, FieldRole.ROLE_OWNER, clr);
if (JPOXLogger.DATASTORE.isDebugEnabled())
{
debugMapping(ownerMapping);
}
// Add key mapping
boolean keyPC = (fmd.hasMap() && fmd.getMap().getKeyClassMetaData() != null);
if (isSerialisedKey() || isEmbeddedKeyPC() || (isEmbeddedKey() && !keyPC))
{
// Key = PC(embedded), PC(serialised), Non-PC(serialised), Non-PC(embedded)
keyMapping = dba.getMappingManager().getMapping(this, fmd, dba, clr, JavaTypeMapping.MAPPING_MAP_KEY);
if (JPOXLogger.DATASTORE.isDebugEnabled())
{
debugMapping(keyMapping);
}
}
else
{
// Key = PC
ColumnMetaData[] keyColmd = null;
KeyMetaData keymd = fmd.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(clr.classForName(mmd.getKeyType()), fmd,
keyColmd, storeMgr, this, false, false, fmd.getMap().isSerializedKey(), false,
FieldRole.ROLE_MAP_KEY, clr);
if (JPOXLogger.DATASTORE.isDebugEnabled())
{
debugMapping(keyMapping);
}
}
// Add value mapping
boolean valuePC = (fmd.hasMap() && fmd.getMap().getValueClassMetaData() != null);
if (isSerialisedValue() || isEmbeddedValuePC() || (isEmbeddedValue() && !valuePC))
{
// Value = PC(embedded), PC(serialised), Non-PC(serialised), Non-PC(embedded)
// Add field(s) for value
valueMapping = dba.getMappingManager().getMapping(this, fmd, dba, clr, JavaTypeMapping.MAPPING_MAP_VALUE);
if (JPOXLogger.DATASTORE.isDebugEnabled())
{
debugMapping(valueMapping);
}
}
else
{
// Value = PC
ColumnMetaData[] valueColmd = null;
ValueMetaData valuemd = fmd.getValueMetaData();
if (valuemd != null && valuemd.getColumnMetaData() != null && valuemd.getColumnMetaData().length > 0)
{
// Column mappings defined at this side (1-N, M-N)
valueColmd = valuemd.getColumnMetaData();
}
valueMapping = ColumnCreator.createColumnsForJoinTables(clr.classForName(mmd.getValueType()), fmd,
valueColmd, storeMgr, this, false, true, fmd.getMap().isSerializedValue(), false,
FieldRole.ROLE_MAP_VALUE, clr);
if (JPOXLogger.DATASTORE.isDebugEnabled())
{
debugMapping(valueMapping);