Package org.hibernate.annotations
Annotation Type Any
-
@Target({METHOD,FIELD}) @Retention(RUNTIME) public @interface Any
Maps a discriminated to-one style association pointing to one of several entity types depending on a local discriminator, as opposed to discriminated inheritance where the discriminator is kept as part of the entity hierarchy (seeInheritance
andInheritanceType.SINGLE_TABLE
for details about discriminated inheritance mappings). For example, if you consider anOrder
entity containingPayment
information wherePayment
might be of typeCashPayment
orCreditCardPayment
, the@Any
approach would be to keep that discriminator and matching value on theOrder
itself instead as part of thePayment
class. Thought of another way, the "foreign key" is really made up of the value and discriminator. Note however that this composite foreign-key is a conceptual and cannot be physical.- Use
Column
orFormula
to define the "column" to which the discriminator is mapped. - Use
JoinColumn
to describe the key column - Use
AnyDiscriminator
,JdbcType
orJdbcTypeCode
to describe the mapping for the discriminator - Use
AnyKeyJavaType
,AnyKeyJavaClass
,AnyKeyJdbcType
orAnyKeyJdbcTypeCode
to describe the mapping for the key - Use
AnyDiscriminatorValues
to specify how discriminator values map to entity types
- See Also:
ManyToAny
- Use
-
-
Element Detail
-
fetch
jakarta.persistence.FetchType fetch
Defines whether the value of the field or property should be lazily loaded or must be eagerly fetched. The EAGER strategy is a requirement on the persistence provider runtime that the value must be eagerly fetched. The LAZY strategy is applied when bytecode enhancement is used. If not specified, defaults to EAGER.- Default:
- jakarta.persistence.FetchType.EAGER
-
-