Skip to content

Latest commit

 

History

History
152 lines (121 loc) · 6.29 KB

AnnotationReference.wiki

File metadata and controls

152 lines (121 loc) · 6.29 KB

  1. summary The annotations used by Objectify

Table of Contents

Example

The Annotations

@com.googlecode.objectify.annotation.Entity

  * Required for all registered entity classes.
  * Optionally specifies the name of a kind, ie {{{@Entity(name="Person")}}}

@com.googlecode.objectify.annotation.Id

  * Must be placed on one and only one field of an @Entity class
  * Field must be type {{{Long}}}, {{{long}}}, or {{{String}}}
  * If used on type {{{Long}}}, null values will be autogenerated on put()

@com.googlecode.objectify.annotation.Parent

  * Placed on at most one field of type {{{Key}}}
  * Defines the entity group parent for an entity

@com.googlecode.objectify.annotation.Subclass

  * Placed on subclasses of polymorphic types, both {{{@Entity}}} and embedded
  * Exclusive with {{{@Entity}}}
  * See [http://code.google.com/p/objectify-appengine/wiki/Entities#Polymorphism Polymorphism].

@com.googlecode.objectify.annotation.Index

  * Placed on a field or class.
  * When placed on a class, sets the default state for all fields of the class.
  * Can take {{{If}}} conditions which allow partial indexing.
  * @Index state is inherited by embedded classes and their fields, but can be overriden with @Unindex.
  * Indexed fields cost more space and cpu time to store, but can be queried on.
  * Translates to {{{Entity.setProperty()}}} at the low-level api.
  * Unless otherwise specified, all classes default to @Unindex.

@com.googlecode.objectify.annotation.Unindex

  * Placed on a field or class.
  * When placed on a class, sets the default state for all fields of the class.
  * Can take {{{If}}} conditions which allow partial indexing.
  * @Unindex state is inherited by embedded classes and their fields, but can be overridden with @Index.
  * Unindexed fields consume less space and require less cpu time to store, but cannot be queried for.
  * Translates to {{{Entity.setUnindexedProperty()}}} at the low-level api.

@com.googlecode.objectify.annotation.Ignore

  * Placed on any field
  * Makes the field opaque to storage in the datastore; the field will be ignored for both read and write.

@com.googlecode.objectify.annotation.IgnoreSave

  * Placed on any field
  * Field will be loaded from the datastore but won't be saved
  * Can take {{{If}}} conditions which allow some values to be saved and not others.

@com.googlecode.objectify.annotation.IgnoreLoad

  * Placed on any field
  * Field will be saved to the datastore but will be ignored during load operations

@com.googlecode.objectify.annotation.AlsoLoad

  * Placed on a field or the single parameter to a method
  * Requires one value, the name of a property in the datastore to load into the field.
  * Example:  {{{@AlsoLoad("whatThisFieldUsedToBeCalled")}}}
  * Causes the field to be loaded from an alternate name in the underlying datastore
  * If placed on the parameter to a method that takes a single parameter, the method will be called with the datastore value
  * Can be used on multiple fields; they will all receive the loaded value.

@com.googlecode.objectify.annotation.Cache

  * Placed on an entity class
  * Stores entity data in a write-through cache for faster read performance
  * Allows you to specify the expiration of entities in the cache

@com.googlecode.objectify.annotation.Serialize

  * Placed on any entity field of Serializable type
  * Causes the object graph at that point to be stored as a serialized Blob.
  * You can optionally configure zipping and compression level.
  * See the [http://code.google.com/p/objectify-appengine/wiki/Entities#Serializing serializing] documentation.

@com.googlecode.objectify.annotation.OnLoad

  * Placed on any method that takes no parameters.
  * Called after the POJO is populated with data.
  * Can be specified on multiple methods in this class or any base class.
  * Methods are called in declared order, with superclass methods first.
  * See LifecycleCallbacks

@com.googlecode.objectify.annotation.OnSave

  * Placed on any method that takes no parameters.
  * Called before the POJO is written to the datastore Entity.
  * Can be specified on multiple methods in this class or any base class.
  * Methods are called in declared order, with superclass methods first.
  * See LifecycleCallbacks

@com.googlecode.objectify.annotation.Load

  * Placed on entity fields of type {{{Ref<?>}}}
  * Causes the referenced entity to be loaded automatically
  * Load groups can be specified to limit when loading occurs
  * See [http://code.google.com/p/objectify-appengine/wiki/Entities#Relationships Relationships]

@com.googlecode.objectify.annotation.Mapify

  * TODO: This needs some explanation.
  * See the javadocs for details.

@com.googlecode.objectify.annotation.Stringify

  * TODO: This needs some explanation.
  * See the javadocs for details.

@com.googlecode.objectify.annotation.Container

  * TODO: This needs some explanation.
  * See the javadocs for details.

@com.googlecode.objectify.annotation.Translate

  * TODO: This needs some explanation.
  * See the javadocs for details.