sm.initialiseForHollow(null, null, value.getClass());
sm.copyFieldsFromObject((PersistenceCapable) value, acmd.getPKMemberPositions());
jdoPrimaryKey = sm.provideField(acmd.getPKMemberPositions()[0]);
}
if (jdoPrimaryKey == null) {
throw new FatalNucleusUserException(
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 (!qd.tableMap.get(ammd.getAbstractClassMetaData().getFullClassName()).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 FatalNucleusUserException(
query.getSingleStringQuery() + ": Cannot query for parents with null children.");
}
if (valueKey.getParent() == null) {
throw new FatalNucleusUserException(
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 FatalNucleusUserException(
query.getSingleStringQuery() + ": The datastore does not support querying for objects with null parents.");
} else {
addParentFilter(op, valueKey, qd.primaryDatastoreQuery);
}
}