Package org.hibernate.annotations
A set of mapping annotations which extend the O/R mapping annotations defined by JPA.
Basic value mapping
Hibernate supports two approaches to defining a mapping strategy for basic values:-
A "compositional" approach using a combination of the following influencers for
various parts of mapping
JavaTypeJdbcTypeJdbcTypeCodeMutabilityAttributeConverter/ConvertLobEnumeratedTemporalNationalized
JavaType,JdbcType,JdbcTypeCodeandMutabilityall have specialized forms for the various model parts such as map-key, list-index, (id-bag) collection-id, etc. -
Contracted via the
UserTypeinterface and specified usingType. As with the compositional approach, there are model-part specific annotations for specifying custom-types as well.
Please see the user guide for a more in-depth discussion.
-
Interface Summary Interface Description DialectOverride Allows certain annotations to be overridden in a given SQLDialect. -
Class Summary Class Description NoAttributeConverter<O,R> Deprecated. this class is no longer usedQueryHints Deprecated. UseAvailableHintsinstead -
Enum Summary Enum Description CacheConcurrencyStrategy Identifies policies for managing concurrent access to the shared second-level cache.CacheModeType Deprecated. CascadeType Enumerates the persistence operations which may be cascaded from one entity instance to associated entity instances.FetchMode Enumerates strategies for fetching an association from the database.FlushModeType Enumeration extending the JPA flush modes with flush modes specific to Hibernate, and a "null" mode,FlushModeType.PERSISTENCE_CONTEXT, for use as a default annotation value.GenerationTime Deprecated. useEventTypeandEventTypeSetsinsteadLazyCollectionOption Deprecated. Use the JPA-definedFetchType.EAGERinstead ofLazyCollection(FALSE).LazyToOneOption Deprecated. NotFoundAction Specifies how Hibernate should handle the case of an orphaned foreign key with no associated row in the referenced table.OnDeleteAction Enumerates the possible actions for theon deleteclause of a foreign key constraint.OptimisticLockType Enumerates the possible optimistic lock checking strategies.PolymorphismType Specifies whether implicit polymorphism is enabled or disabled.ResultCheckStyle Enumerates strategies for checking JDBC return codes for custom SQL DML queries.SourceType Specifies the source of a generated value, either the virtual machine, or the database.TimeZoneStorageType Describes the storage of timezone information for zoned datetime types, in particular, for the typesOffsetDateTimeandZonedDateTime.UuidGenerator.Style -
Annotation Types Summary Annotation Type Description Any Maps a to-one cardinality association taking values over several entity types which are not related by the usual entity inheritance, using a discriminator value stored on the referring side of the relationship.AnyDiscriminator A simplified way to specify the type of the discriminator in anAnymapping, using the JPA-definedDiscriminatorType.AnyDiscriminatorValue Specifies the mapping of a single any-valued discriminator value to its corresponding entity type.AnyDiscriminatorValues List ofAnyDiscriminatorValues.AnyKeyJavaClass Specifies the Java class to use for the foreign key handling related to anAnymapping.AnyKeyJavaType Form ofJavaTypeused to describe the foreign-key part of an ANY mapping.AnyKeyJdbcType AnyKeyJdbcTypeCode Form ofJdbcTypeCodeused to describe the foreign key part of anAnymapping.AttributeAccessor Specifies an attribute access strategy to use.AttributeBinderType Associates a user-defined annotation with anAttributeBinder, allowing the annotation to drive some custom model binding.Bag Can be used to map aList-valued attribute usingCollectionClassification.BAGsemantics.BatchSize Specifies a maximum batch size for batch fetching of the annotated entity or collection.Cache Marks a root entity or collection for second-level caching, and specifies: a named cache region in which to store the state of instances of the entity or collection, and an appropriate cache concurrency policy, given the expected data access patterns affecting the entity or collection.Cascade Specifies the persistence operations that should cascade to associated entity instances.Check Specifies acheckconstraint to be included in the generated DDL.CollectionId Describe an identifier column for a bag.CollectionIdJavaType Form ofJavaTypefor describing the id of an id-bag mappingCollectionIdJdbcType Form ofJdbcTypefor describing the id of an id-bag mappingCollectionIdJdbcTypeCode Form ofJdbcTypeCodefor describing the id of an id-bag mappingCollectionIdMutability Form ofMutabilityfor describing the id of an id-bag mappingCollectionIdType Form ofTypefor describing the id of an id-bag mappingCollectionType Names a custom collection type for a persistent collection.CollectionTypeRegistration Allows to register aUserCollectionTypeto use as the default for the specified classification of collection.CollectionTypeRegistrations Repeatable container forCollectionTypeRegistrationColumnDefault Specifies that a column has adefaultvalue specified in DDL.Columns Support an array of columns.ColumnTransformer Specifies custom SQL expressions used to read and write to the column mapped by the annotated persistent attribute in all generated SQL involving the annotated persistent attribute.ColumnTransformers Plural annotation for @ColumnTransformer.Comment Specifies a comment that will be included in generated DDL.CompositeType Specifies a customCompositeUserTypefor the annotated attribute mapping.CompositeTypeRegistration Registers a custom composite user type implementation to be used by default for all references to a particular embeddable class.CompositeTypeRegistrations Grouping ofCompositeTypeRegistrationConverterRegistration Registers anAttributeConverter.ConverterRegistrations CreationTimestamp Specifies that the annotated field of property is a generated creation timestamp.CurrentTimestamp Specifies that the annotated field of property is a generated timestamp, and also specifies the timing of the timestamp generation, and whether it is generated in Java or by the database:source = VMindicates that the virtual machine current instant is used, andsource = DBindicates that the databasecurrent_timestampfunction should be used.DialectOverride.Check Specializes aCheckin a certain dialect.DialectOverride.Checks DialectOverride.ColumnDefault Specializes aColumnDefaultin a certain dialect.DialectOverride.ColumnDefaults DialectOverride.DiscriminatorFormula Specializes aDiscriminatorFormulain a certain dialect.DialectOverride.DiscriminatorFormulas DialectOverride.FilterDefOverrides DialectOverride.FilterDefs SpecializesFilterDefsin a certain dialect.DialectOverride.FilterOverrides DialectOverride.Filters SpecializesFiltersin a certain dialect.DialectOverride.Formula Specializes aFormulain a certain dialect.DialectOverride.Formulas DialectOverride.GeneratedColumn Specializes aGeneratedColumnin a certain dialect.DialectOverride.GeneratedColumns DialectOverride.JoinFormula Specializes aJoinFormulain a certain dialect.DialectOverride.JoinFormulas DialectOverride.OrderBy Specializes anOrderByin a certain dialect.DialectOverride.OrderBys DialectOverride.OverridesAnnotation Marks an annotation type as a dialect-specific override for some other annotation type.DialectOverride.Version Identifies a database version.DialectOverride.Where Specializes aWherein a certain dialect.DialectOverride.Wheres DiscriminatorFormula Specifies an expression written in native SQL as the discriminator for an entity inheritance hierarchy.DiscriminatorOptions Optional annotation used in conjunction with the JPA-definedDiscriminatorColumnannotation to express Hibernate-specific discriminator properties.DynamicInsert Specifies that SQLinsertstatements for the annotated entity are generated dynamically, and only include the columns to which a non-null value must be assigned.DynamicUpdate Specifies that SQLupdatestatements for the annotated entity are generated dynamically, and only include columns which are actually being updated.EmbeddableInstantiator Specifies a custom instantiator for a specific embeddedEmbeddableInstantiatorRegistration Registers a custom instantiator implementation to be used for all references to a particularEmbeddable.EmbeddableInstantiatorRegistrations Grouping ofEmbeddableInstantiatorRegistrationFetch Specifies the default fetching strategy for the annotated association.FetchProfile Defines a fetch profile, by specifying itsFetchProfile.name(), together with a list of fetch strategy overrides.FetchProfile.FetchOverride Overrides the fetching strategy pf a particular association in the named fetch profile being defined.FetchProfiles Collects together multiple fetch profiles.Filter Specifies that an entity or collection is affected by a named filter declared usingFilterDef, and allows the default filter condition to be overridden for the annotated entity or collection role.FilterDef Declares a filter, specifying its FilterDef.name(), optionally, a default condition, and its parameter names and types, if it has parameters.FilterDefs Array of filter definitions.FilterJoinTable Specifies that the join table of a collection is affected by a named filter declared usingFilterDef, and allows the default filter condition to be overridden for the annotated entity or collection role.FilterJoinTables Add multiple@FilterJoinTableto a collection.Filters Add multiple@Filters.ForeignKey Deprecated, for removal: This API element is subject to removal in a future version. use the JPA 2.1ForeignKeyannotationFormula Specifies an expression written in native SQL that is used to read the value of an attribute instead of storing the value in aColumn.Generated Specifies that the value of the annotated property is generated by the database.GeneratedColumn Specifies that a column is defined using a DDLgenerated always asclause or equivalent, and that Hibernate should fetch the generated value from the database after each SQLINSERTorUPDATE.GeneratorType Deprecated. ValueGenerationTypeandAnnotationValueGenerationnow provide a much more powerful and typesafe alternativeGenericGenerator Defines a named identifier generator, usually an instance of the interfaceIdentifierGenerator.GenericGenerators Array of generic generator definitions.IdGeneratorType Meta-annotation used to mark another annotation as providing configuration for a custom identifier generator.Immutable Marks an entity, collection, or attribute of an entity as immutable.Imported Marks an arbitrary class as available for use in HQL queries by its unqualified name.Index Deprecated. UseIndexinstead.IndexColumn Deprecated. Prefer the standard JPAOrderColumnannotation and the Hibernate specificListIndexBase(for replacingIndexColumn.base()).Instantiator Marks the canonical constructor to be used for instantiation of an embeddable.JavaType Specify an explicitBasicJavaTypeto use for a particular column mapping.JavaTypeRegistration Registers the BasicJavaType to use for the givenJavaTypeRegistration.javaType()JavaTypeRegistrations Grouping ofJavaTypeRegistrationSee notes onJavaTypeRegistrationabout using on packages versus use on classesJdbcType Specifies an explicitJdbcTypeto use for a particular column mapping. When applied to a Map-valued attribute, describes the Map value.JdbcTypeCode Specifies the JDBC type-code to use for the column mapping. When applied to a Map-valued attribute, describes the Map value.JdbcTypeRegistration Describes a SqlTypeDescriptor to be added to theJdbcTypeRegistryJdbcTypeRegistrations Grouping ofJdbcTypeRegistrationSee notes onJdbcTypeRegistrationabout using on packages versus use on classesJoinColumnOrFormula JoinColumnsOrFormulas JoinFormula Specifies a join condition based on an arbitrary native SQL formula instead of a column name.LazyCollection Deprecated. Use the JPA-definedFetchType.EAGERinstead ofLazyCollection(FALSE).LazyGroup Specifies the fetch group for a persistent attribute of an entity class.LazyToOne Deprecated. use JPA annotations to specify theFetchTypeListIndexBase Specifies the base value for theorder columnof a persistent list or array, that is, the order column value of the first element of the list or array.ListIndexJavaType Form ofJavaTypefor describing the column mapping for the index of a List or arrayListIndexJdbcType Form ofJdbcTypefor describing the column mapping for the index of a List or arrayListIndexJdbcTypeCode Form ofJdbcTypeCodefor describing the column mapping for the index of a List or arrayLoader Specifies that a named query should be used to load an entity, overriding the SQL that Hibernate generates by default.ManyToAny Maps a to-many cardinality association taking values over several entity types which are not related by the usual entity inheritance, using a discriminator value stored in an association table.MapKeyCompositeType Form ofCompositeTypefor use with map-keysMapKeyJavaType Form ofJavaTypefor describing the key of a MapMapKeyJdbcType Form ofJdbcTypefor describing the key of a MapMapKeyJdbcTypeCode Form ofJdbcTypeCodefor describing the key of a MapMapKeyMutability Form ofMutabilityfor describing the key of a MapMapKeyType Form ofTypefor use with map-keysMutability Specifies aMutabilityPlanfor a basic value mapping.NamedNativeQueries A grouping of Hibernate-specificNamedNativeQuerydefinitions.NamedNativeQuery Declares a named query written in native SQL.NamedQueries A grouping of Hibernate-specificNamedQuerydefinitions.NamedQuery Declares a named query written in HQL or JPQL.Nationalized Specifies that the annotated character data should be stored with nationalization support.NaturalId Specifies that a field or property of an entity class is part of the natural id of the entity.NaturalIdCache Specifies that mappings from the natural id values of the annotated entity to the corresponding entity id values should be cached in the shared second-level cache.NotFound Indicates that a many to one, one to one, or many to many association maps to a column holding foreign keys, but without a foreign key constraint, and which may therefore violate referential integrity.OnDelete Specifies anon deleteaction for a foreign key constraint.OptimisticLock Specifies whether mutating the annotated attribute should trigger an increment to theversionof the entity instance.OptimisticLocking Specifies how optimistic lock checking works for the annotated entity.OrderBy Order a collection using an expression written in native SQL.ParamDef Details about a parameter declared in aFilterDef.Parameter Generic parameter (basically a key/value combination) used to parametrize other annotations.Parent Reference the property as a pointer back to the owner (generally the owning entity).PartitionKey Identifies a field of an entity that holds the partition key of a table.Persister Specify a custom persister.Polymorphism Deprecated. This annotation is hardly ever useful.Proxy Deprecated. This annotation is almost never useful.RowId Specifies that an Oracle-stylerowidshould be used in SQLupdatestatements for an entity, instead of the primary key.SecondaryRow Specifies how the row of aSecondaryTableshould be managed.SecondaryRows A grouping ofSecondaryRows.SelectBeforeUpdate Deprecated. SinceSession.update(Object)is deprecatedSortComparator SortNatural Source Deprecated. useCurrentTimestampinsteadSQLDelete Specifies a custom SQL DML statement to be used in place of the default SQL generated by Hibernate when an entity or collection row is deleted from the database.SQLDeleteAll Specifies a custom SQL DML statement to be used in place of the default SQL generated by Hibernate when an entire collection is deleted from the database.SQLDeletes A grouping ofSQLDeletes.SqlFragmentAlias Defines an interpolated alias occurring in a SQL filter condition.SQLInsert Specifies a custom SQL DML statement to be used in place of the default SQL generated by Hibernate when an entity or collection row is inserted in the database.SQLInserts A grouping ofSQLInserts.SQLUpdate Specifies a custom SQL DML statement to be used in place of the default SQL generated by Hibernate when an entity or collection row is updated in the database.SQLUpdates A grouping ofSQLUpdates.Struct Specifies the UDT (user defined type) name for the annotated embeddable or embedded.Subselect Maps an immutable and read-only entity to a given SQLselectexpression.Synchronize Specifies the tables that hold state mapped by the annotated derived entity, ensuring that auto-flush happens correctly and that queries against the derived entity do not return stale data.Table Complementary information for a table declared using theTable, orSecondaryTableannotation.Tables A grouping ofTables.Target Deprecated. use annotation members of JPA association mapping annotations, for example,OneToMany.targetEntity()TenantId Identifies a field of an entity that holds a tenant id in discriminator-based multitenancy.TimeZoneColumn Specifies the mapped column for storing the time zone information, for use in conjunction withTimeZoneStorageType.COLUMNorTimeZoneStorageType.AUTO.TimeZoneStorage Specifies how the time zone information of a persistent property or field should be persisted.Type Specifies a customUserTypefor the annotated attribute mapping.TypeRegistration Registers a custom user type implementation to be used by default for all references to a particular basic type.TypeRegistrations Grouping ofTypeRegistrationUpdateTimestamp Specifies that the annotated field of property is a generated update timestamp. The timestamp is regenerated every time an entity instance is updated in the database.UuidGenerator Specifies that an entity identifier is generated as an RFC 4122 UUID.ValueGenerationType Meta-annotation used to mark another annotation as providing configuration for a custom value generation strategy.Where Specifies a restriction written in native SQL to add to the generated SQL when querying an entity or collection.WhereJoinTable Specifies a restriction written in native SQL to add to the generated SQL when querying thejoin tableof a collection.