*/
protected String getReferenceStringForObject(ObjectManager om, Object value)
{
if (om.getApiAdapter().isPersistable(value))
{
StateManager sm = om.findStateManager(value);
if (sm == null)
{
// Referenced object is not yet persistent, so persist it
om.persistObjectInternal(value, null, null, -1, StateManager.PC);
sm = om.findStateManager(value);
sm.flush(); // Make sure the object is in the datastore so the id is set
}
if (sm != null)
{
String refString = null;
if (mappingStrategy == ID_MAPPING)
{
refString = value.getClass().getName() + ":" + sm.getInternalObjectId();
}
else if (mappingStrategy == XCALIA_MAPPING)
{
AbstractClassMetaData cmd = sm.getClassMetaData();
DiscriminatorMetaData dismd = cmd.getDiscriminatorMetaDataForTable();
String definer = null;
if (dismd != null && dismd.getValue() != null)
{
definer = dismd.getValue();
}
else
{
definer = cmd.getFullClassName();
}
if (cmd.getIdentityType() == IdentityType.DATASTORE)
{
refString = definer + ":" + ((OID)sm.getInternalObjectId()).getKeyValue();
}
else
{
refString = definer + ":" + sm.getInternalObjectId().toString();
}
}
return refString;
}
else