bExpr = expr.expressionList.getExpression(0).eq(oidExpr);
}
else
{
ApiAdapter api = qs.getStoreManager().getApiAdapter();
AbstractClassMetaData cmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(value.getClass(), clr);
if (cmd == null)
{
// if there is no metadata, we either have an SingleFieldIdentity, application identity, or any object
if (storeMgr.getApiAdapter().isSingleFieldIdentityClass(value.getClass().getName()))
{
// Object is SingleFieldIdentity
JavaTypeMapping m = dba.getMapping(api.getTargetClassForSingleFieldIdentity(value), storeMgr, clr);
ScalarExpression oidExpr = m.newLiteral(qs, api.getTargetKeyForSingleFieldIdentity(value));
bExpr = expr.expressionList.getExpression(0).eq(oidExpr);
}
else
{
String pcClassName = storeMgr.getClassNameForObjectID(value, clr, null);
if (pcClassName != null)
{
// Object is an application identity
cmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(pcClassName, clr);
bExpr = eqApplicationIdentity(value, null, expr, null, storeMgr, clr);
}
else
{
// Value not PersistenceCapable nor an identity, so return nothing "(1 = 0)"
bExpr = new BooleanLiteral(qs, mapping, false).eq(new BooleanLiteral(qs, mapping, true));
}
}
}
else
{
// Value is a PersistenceCapable
if (cmd.getIdentityType() == IdentityType.APPLICATION)
{
// Application identity
if (api.getIdForObject(value) != null)
{
// Persistent PC object (FCO)
// Cater for composite PKs and parts of PK being PC mappings, and recursion
JavaTypeMapping[] pkMappingsApp = new JavaTypeMapping[expr.expressionList.size()];
Object[] pkFieldValues = new Object[expr.expressionList.size()];
int position = 0;
for (int i=0;i<cmd.getNoOfPrimaryKeyMembers();i++)
{
AbstractMemberMetaData mmd = cmd.getMetaDataForManagedMemberAtAbsolutePosition(cmd.getPKMemberPositions()[i]);
Object fieldValue = getFieldValue(mmd, value);
JavaTypeMapping mapping = dba.getMapping(fieldValue.getClass(), storeMgr, clr);
if (mapping instanceof PersistenceCapableMapping)
{
position = populatePrimaryKeyMappingsValuesForPCMapping(pkMappingsApp,