Annotation Type Subclass
Indicates that a class is part of a polymorphic persistence hierarchy. Subclasses of an @Entity should be flagged with this annotation.
This is used for Objectify's implementation of polymorphism. Place this on any class in an inheritance hierarchy that should be queryable except the root. For example, in the hierarchy Animal->Mammal->Cat, annotations should be:
- @Entity Animal
- @Subclass(index=true) Mammal
- @Subclass(index=true) Cat
The @Entity annotation must be present on the class that identifies the root of the hierarchy. This class will define the kind of the entire hierarchy. The @Entity annotation must NOT be present on any subclasses.
Actual Java subclasses are not required to have @Subclass, but only Java classes which have @Subclass can be persisted and queried for. Note that subclass discriminators are not indexed by default, so if you want to query for specific types of subclasses, use @Subclass(index=true).
- Author:
- Jeff Schnitzer
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionString[]
Additional discriminators which, when encountered, will be interpreted as indicating this subclass.boolean
If true, the discriminator will be indexed, and a query for the specific subclass will return results.Optionally define the discriminator value for the subclass; default is Class.getSimpleName()
-
Element Details
-
name
String nameOptionally define the discriminator value for the subclass; default is Class.getSimpleName()- Default:
""
-
index
boolean indexIf true, the discriminator will be indexed, and a query for the specific subclass will return results. However, superclasses and further subclasses may be have different index states.
This is NOT the same as putting @Index on a class; that sets the default index state of the fields of that class. This attribute only controls indexing of the discriminator.
- Default:
false
-
alsoLoad
String[] alsoLoadAdditional discriminators which, when encountered, will be interpreted as indicating this subclass. Facilitates schema changes in a way analagous to @AlsoLoad.- Default:
{}
-