protected final Object fetch(Key<?> id) { return p.get().getByKey(referenceObjClass, id); }
@Override protected synchronized Object fetch() { Collection<T> c = (Collection<T>) object; c.clear(); int numberOfEntitiesExpected = listOfKeys.size(); // does not retain order: // List<T> retrievedEntities = p.get().getByKeys(referenceObjClass, // (List) __getKeysAsList()); // so we do it the lousy way: FIXME List<T> retrievedEntities = new ArrayList<T>(listOfKeys.size()); Datastore ds = p.get(); for (Key<?> k : listOfKeys) { retrievedEntities.add((T) ds.getByKey(referenceObjClass, k)); } if (!ignoreMissing && (numberOfEntitiesExpected != retrievedEntities.size())) { throw new LazyReferenceFetchingException("During the lifetime of a proxy of type '" + c.getClass().getSimpleName() + "', some referenced Entities of type '" + referenceObjClass.getSimpleName() + "' have disappeared from the Datastore."); } c.addAll(retrievedEntities); return c; }
@Override protected Object fetch() { Object entity = p.get().getByKey(referenceObjClass, key); if (entity == null) { throw new LazyReferenceFetchingException( "During the lifetime of the proxy, the Entity identified by '" + key + "' disappeared from the Datastore."); } return entity; }