Annotation Type Polymorphism
@Deprecated(since="6.2") @Target(TYPE) @Retention(RUNTIME) public @interface PolymorphismDeprecated.This annotation is hardly ever useful.Allows implicit polymorphism to be disabled for an entity class hierarchy, by annotating the root entity
Hibernate allows a query
fromclause to name a mapped superclass, or even an arbitrary Java type which is neither an entity class nor a mapped superclass. The query will return all entities which inherit the type. For example, the query
will return every entity mapped by Hibernate!
This can be thought of as allowing a sort of "poor man's" table per class inheritance, though it comes with many limitations.
This annotation allows an entity class to refuse to participate in such a crazy query, so that it's never returned by any query that names one of its non-entity supertypes.
Note that this annotation may only be applied to the root entity in an entity inheritance hierarchy, and its effect is inherited by entity subclasses.
Note also that this has no effect at all on the usual polymorphism within a mapped entity class inheritance hierarchy, as defied by the JPA specification. "Implicit" polymorphism is about queries that span multiple such entity inheritance hierarchies.
PolymorphismType typeDeprecated.Determines whether implicit polymorphism is enabled or disabled for the annotated entity class. It is enabled by default.