Annotation Interface Polymorphism
@Polymorphism(type=EXPLICIT).
Hibernate allows a query from clause 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
from java.lang.Object
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.
- Author:
- Steve Ebersole
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionDeprecated.Determines whether implicit polymorphism is enabled or disabled for the annotated entity class.
-
Element Details
-
type
PolymorphismType typeDeprecated.Determines whether implicit polymorphism is enabled or disabled for the annotated entity class. It is enabled by default.- Default:
- IMPLICIT
-