// the object doesn't have the PK field(s) set, so access it via IdentityUtils
Object jdoID = apiAdapter.getNewApplicationIdentityObjectId(value, acmd);
jdoPrimaryKey = apiAdapter.getTargetKeyForSingleFieldIdentity(jdoID);
}
if (jdoPrimaryKey == null) {
throw new NucleusFatalUserException(query.getSingleStringQuery() + ": Parameter value " + value + " does not have an id.");
}
}
Key valueKey = null;
if (jdoPrimaryKey != null) {
valueKey = internalPkToKey(acmd, jdoPrimaryKey);
verifyRelatedKeyIsOfProperType(ammd, valueKey, acmd);
}
if (!MetaDataUtils.isOwnedRelation(ammd, getStoreManager())) {
// Add filter on 1-1 relation field
qd.primaryDatastoreQuery.addFilter(determinePropertyName(ammd), Query.FilterOperator.EQUAL, valueKey);
return;
}
if (!qd.table.isParentKeyProvider(ammd)) {
// Looks like a join. If it can be satisfied by just extracting the
// parent key from the provided key, fulfill it.
if (op != Query.FilterOperator.EQUAL) {
throw new UnsupportedDatastoreFeatureException(
"Only the equals operator is supported on conditions involving the owning side of a "
+ "one-to-one.");
}
if (valueKey == null) {
// User is asking for parents where child is null. Unfortunately we
// don't have a way to fulfill this because one-to-one is actually
// implemented as a one-to-many
throw new NucleusFatalUserException(
query.getSingleStringQuery() + ": Cannot query for parents with null children.");
}
if (valueKey.getParent() == null) {
throw new NucleusFatalUserException(
query.getSingleStringQuery() + ": Key of parameter value does not have a parent.");
}
// The field is the child side of an owned one to one. We can just add
// the parent key to the query as an equality filter on id.
qd.primaryDatastoreQuery.addFilter(
Entity.KEY_RESERVED_PROPERTY, Query.FilterOperator.EQUAL, valueKey.getParent());
} else if (valueKey == null) {
throw new NucleusFatalUserException(
query.getSingleStringQuery() + ": The datastore does not support querying for objects with null parents.");
} else {
addParentFilter(op, valueKey, qd.primaryDatastoreQuery);
}
}