AnnotationReference - objectify/objectify GitHub Wiki
The annotations used by Objectify
Example
@Cache(expirationSeconds=600)
@Entity(name="Emp")
@Index// or @Unindex sets default for fields in class; if neither specified, default is @UnindexclassEmployee {
@Idlongid;
@ParentKey<Company> employer;
@UnindexintvacationDays;
// field value WILL be serialized (eg, with GWT) but will NOT be persisted in the datastore@IgnoreintnotPersistent;
// field value will NOT be serialized (eg, with GWT) but WILL be persisted in the datastoretransientintnotSerialized;
// field getting renamed@AlsoLoad("boss") Key<Employee> manager;
StringfirstName;
StringlastName;
// we used to store fullName, now we store first and last separatelypublicvoidoldWay(@AlsoLoad("fullName") StringfullName) {
String[] split = fullName.split(" ");
firstName = split[0];
lastName = split[1];
}
staticclassOffice {
Stringbuilding;
Stringroom;
}
// Allows you to query for employess in a building by filtering on "offices.building"Office[] offices;
// Whatever gets put here will be serialized out and back (and cannot be filtered)@SerializeObjectmisc;
@OnLoadvoidonLoad() { /* do something after load */ }
@OnSavevoidonSave() { /* do something before persisting */ }
}
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