this.emd = emd;
this.typeName = typeName;
this.objectType = (short) objectType;
// Find the MetaData for the embedded PC class
MetaDataManager mmgr = datastoreContainer.getStoreManager().getMetaDataManager();
AbstractClassMetaData pcCmd = mmgr.getMetaDataForClass(typeName, clr);
if (pcCmd == null)
{
// Not found so must be an interface
if (fmd != null)
{
// Try using the fieldTypes on the field/property - we support it if only 1 implementation
String[] fieldTypes = fmd.getFieldTypes();
if (fieldTypes != null && fieldTypes.length == 1)
{
pcCmd = mmgr.getMetaDataForClass(fieldTypes[0], clr);
}
else if (fieldTypes != null && fieldTypes.length > 1)
{
// TODO Cater for multiple implementations
throw new NucleusUserException("Field " + fmd.getFullFieldName() +
" is a reference field that is embedded. " +
"DataNucleus doesnt support embedded reference fields that have more than 1 implementation");
}
}
if (pcCmd == null)
{
// Try a persistent interface
pcCmd = mmgr.getMetaDataForInterface(clr.classForName(typeName), clr);
if (pcCmd == null && fmd.getFieldTypes() != null && fmd.getFieldTypes().length == 1)
{
// No MetaData for the type so try "fieldType" specified on the field
pcCmd = mmgr.getMetaDataForInterface(clr.classForName(fmd.getFieldTypes()[0]), clr);
}
}
}
embCmd = pcCmd;