Class LiveRef<T>

java.lang.Object
com.googlecode.objectify.Ref<T>
com.googlecode.objectify.impl.ref.LiveRef<T>
All Implemented Interfaces:
Serializable, Comparable<Ref<T>>

public class LiveRef<T> extends Ref<T>

Implementation of Refs which are "live" and connected to the datastore so they can fetch entity values even if they have not already been loaded. This is the standard Ref implementation.

Author:
Jeff Schnitzer invalid input: '<'[email protected]>
See Also:
  • Field Details

    • ofy

      protected transient Objectify ofy
      So that Refs can be associated with a session
  • Constructor Details

    • LiveRef

      protected LiveRef()
      For GWT serialization
    • LiveRef

      public LiveRef(Key<T> key)
      Create a Ref based on the key
    • LiveRef

      public LiveRef(Key<T> key, Objectify ofy)
      Create a Ref based on the key, with the specified session
  • Method Details

    • get

      public T get()
      Description copied from class: Ref
      Obtain the entity value associated with the key. Will pull from session if present, otherwise will fetch from the datastore.
      Specified by:
      get in class Ref<T>
      Returns:
      the entity referenced, or null if the entity was not found
    • isLoaded

      public boolean isLoaded()
      Description copied from class: Ref
      If an entity has been loaded into the session or is otherwise available, this will return true. Calls to get() will not require a trip to backing store. Note that even when loaded, get() can still return null if there is no entity which corresponds to the key.
      Specified by:
      isLoaded in class Ref<T>
      Returns:
      true if the value is in the session or otherwise immediately available; false if get() will require a trip to the datastore or memcache.
    • writeReplace

      protected Object writeReplace() throws ObjectStreamException
      When this serializes, write out the DeadRef version. Use the getValue() for value so that if the value is not loaded, it serializes as null.
      Throws:
      ObjectStreamException