(m instanceof PersistenceCapableMapping || m instanceof InterfaceMapping))
{
int relationType = fmd.getRelationType(clr);
if (relationType == Relation.ONE_TO_ONE_BI)
{
MetaDataManager mmgr = storeMgr.getOMFContext().getMetaDataManager();
if (fmd.getMappedBy() != null)
{
// 1-1 bidirectional (non-owner) field (without datastore column(s))
Class fieldType = fmd.getType();
DatastoreClass relatedTable;
String[] clsNames = null;
if (fieldType.isInterface())
{
if (fmd.getFieldTypes() != null && fmd.getFieldTypes().length == 1)
{
// Use field-type since only one class specified
Class fldTypeCls = clr.classForName(fmd.getFieldTypes()[0]);
if (fldTypeCls.isInterface())
{
// User has specified an interface, so find its implementations
clsNames = mmgr.getClassesImplementingInterface(fmd.getFieldTypes()[0], clr);
}
else
{
// Use user-provided field-type
clsNames = new String[] {fmd.getFieldTypes()[0]};
}
}
if (clsNames == null)
{
clsNames = mmgr.getClassesImplementingInterface(fieldType.getName(), clr);
}
}
else
{
clsNames = new String[] { fieldType.getName() };
}
//only allowed to have association to one table. implementations can be many, but must store to the same table
relatedTable = storeMgr.getDatastoreClass(clsNames[0], clr);
JavaTypeMapping referenceMapping = relatedTable.getFieldMapping(fmd.getMappedBy());
JavaTypeMapping selectMapping = relatedTable.getIDMapping();
JavaTypeMapping refDiscrimMapping = relatedTable.getDiscriminatorMapping(false);
Object[] discrimValues = null;
JavaTypeMapping refTypeMapping = null;
expressionsIndex = new int[referenceMapping.getNumberOfDatastoreFields()];
if (refDiscrimMapping != null)
{
// Related table has a discriminator
DiscriminatorStrategy strategy = relatedTable.getDiscriminatorMetaData().getStrategy();
if (strategy == DiscriminatorStrategy.CLASS_NAME)
{
HashSet allclasses = new HashSet();
if (clsNames != null)
{
for (int i=0;i<clsNames.length;i++)
{
allclasses.add(clsNames[i]);
}
}
for( int i=0; i<clsNames.length; i++)
{
HashSet subclasses = storeMgr.getSubClassesForClass(clsNames[i], true, clr);
if (subclasses != null && subclasses.size() > 0)
{
allclasses.addAll(subclasses);
}
}
discrimValues = allclasses.toArray();
}
else if (strategy == DiscriminatorStrategy.VALUE_MAP)
{
HashSet subclasses = storeMgr.getSubClassesForClass(fmd.getTypeName(), true, clr);
if (subclasses != null && subclasses.size() > 0)
{
int valNo = 0;
discrimValues = new Object[subclasses.size()+1];
discrimValues[valNo++] = fmd.getAbstractClassMetaData().getInheritanceMetaData().getDiscriminatorMetaData().getValue();
Iterator subclassesIter = subclasses.iterator();
while (subclassesIter.hasNext())
{
String subclass = (String)subclassesIter.next();
AbstractClassMetaData subclassCmd = mmgr.getMetaDataForClass(subclass, clr);
discrimValues[valNo++] = subclassCmd.getInheritanceMetaData().getDiscriminatorMetaData().getValue();
}
}
else
{
discrimValues = new Object[1];
discrimValues[0] = mmgr.getMetaDataForClass(fmd.getType(), clr).getInheritanceMetaData().getDiscriminatorMetaData().getValue();
}
}
}
else if (relatedTable != referenceMapping.getDataStoreMapping(0).getDatastoreField().getDatastoreContainerObject())
{