Class EntityMetadata<P>


  • public class EntityMetadata<P>
    extends Object
    Holds basic information about POJO entities, and can translate back and forth to the datastore representation.
    Author:
    Jeff Schnitzer
    • Constructor Detail

      • EntityMetadata

        public EntityMetadata​(ObjectifyFactory fact,
                              Class<P> clazz)
        Parameters:
        clazz - must have @Entity in its hierarchy
    • Method Detail

      • getCacheExpirySeconds

        public Integer getCacheExpirySeconds()
        Get the expiry associated with this kind, defined by the @Cached annotation. For polymorphic types, this is always the instruction on the root @Entity - you cannot provide per-type caching.
        Returns:
        null means DO NOT CACHE, 0 means "no limit", otherwise # of seconds
      • load

        public P load​(com.google.cloud.datastore.BaseEntity<?> ent,
                      LoadContext ctx)
        Converts an entity to an object of the appropriate type for this metadata structure. Does not check that the entity is appropriate; that should be done when choosing which EntityMetadata to call.
      • save

        public com.google.cloud.datastore.FullEntity<?> save​(P pojo,
                                                             SaveContext ctx)
        Converts an object to a datastore Entity with the appropriate Key type.