@Retention(value=RUNTIME) @Target(value=TYPE) public @interface 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:
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 @EntitySubclass, but only Java classes which have @EntitySubclass 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 @EntitySubclass(index=true).
Modifier and Type | Optional Element and Description |
---|---|
String[] |
alsoLoad
Additional discriminators which, when encountered, will be interpreted as indicating
this subclass.
|
boolean |
index
If true, the discriminator will be indexed, and a query for the specific subclass will
return results.
|
String |
name
Optionally define the discriminator value for the subclass; default is Class.getSimpleName()
|
public abstract String name
public abstract boolean index
If 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.
public abstract String[] alsoLoad
Copyright © 2015. All rights reserved.