Class PreGetContext (2.0.0)

public final class PreGetContext extends BaseCallbackContext<Key>

Concrete CallbackContext implementation that is specific to intercepted get() operations. Methods annotated with PreGet that receive instances of this class may modify the result of the get() operation by calling #setResultForCurrentElement(Entity). Keys that receive results via this method will not be fetched from the datastore. This is an effective way to inject cached results.

Inheritance

java.lang.Object > com.google.appengine.api.datastore.BaseCallbackContext > PreGetContext

Methods

setResultForCurrentElement(Entity entity)

public void setResultForCurrentElement(Entity entity)

Set the Entity that will be associated with the Key returned by #getCurrentElement() in the result of the get() operation. This will prevent the get() operation from fetching the Entity from the datastore. This is an effective way to inject cached results.

Parameter
Name Description
entity Entity

The entity to provide as the result for the current element.