Package org.hibernate.annotations
Package containing all Hibernate's specific annotations.
Basic value mapping
Hibernate supports 2 approaches to defining a mapping strategy for basic values:-
A "compositional" approach using a combination of the following influencers for
various parts of mapping
JavaType
JdbcType
JdbcTypeCode
Mutability
AttributeConverter
/Convert
Lob
Enumerated
Temporal
Nationalized
JavaType
,JdbcType
,JdbcTypeCode
andMutability
all have specialized forms for the various model parts such as map-key, list-index, (id-bag) collection-id, etc. -
Contracted via the
UserType
interface and specified usingType
. As with the compositional approach, there are model-part specific annotations for specifying custom-types as well.
-
Interface Summary Interface Description DialectOverride Allows certain annotations to be overridden in a given SQLDialect
. -
Class Summary Class Description CurrentTimestampGeneration Value generation strategy for using the database `current_timestamp` function to generate the valuesNoAttributeConverter<O,R> QueryHints Deprecated. UseAvailableHints
instead -
Enum Summary Enum Description CacheConcurrencyStrategy Cache concurrency strategy.CacheModeType Enumeration for the different interaction modes between the session and the Level 2 Cache.CascadeType Cascade types (can override default JPA cascades).FetchMode How the association should be fetched.FlushModeType Enumeration extendingJPA flush modes
with flush modes specific to Hibernate, and a "null" flush mode,FlushModeType.PERSISTENCE_CONTEXT
for use as a default annotation value.GenerationTime Represents the timing of value generation that occurs in the database.LazyCollectionOption Lazy options available for a collection.LazyToOneOption Lazy options available for a ToOne association.NotFoundAction Specifies how Hibernate should handle the case of an orphaned foreign key with no associated row in the referenced table.OnDeleteAction Possible actions for on-delete.OptimisticLockType Possible optimistic locking strategies.PolymorphismType Type of available polymorphism for a particular entity.ResultCheckStyle Possible styles of checking return codes on SQL INSERT, UPDATE and DELETE queries.SourceType Where should Hibernate retrieve the value from? From the database, or from the current JVM?TimeZoneStorageType Describes the storage of timezone information for zoned datetime types.UuidGenerator.Style -
Annotation Types Summary Annotation Type Description 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).AnyDiscriminator Simplified form for describing the discriminator value mapping as a discrete set.AnyDiscriminatorValue Specifies the mapping for a single any-valued discriminator value to the corresponding entityAnyDiscriminatorValues Grouping of AnyDiscriminatorValueAnyKeyJavaClass Specifies the Java Class to use for the foreign-key handling related to an ANY mapping.AnyKeyJavaType Form ofJavaType
used to describe the foreign-key part of an ANY mapping.AnyKeyJdbcType Form ofJdbcType
used to describe the foreign-key part of an ANY mapping.AnyKeyJdbcTypeCode Form ofJdbcTypeCode
used to describe the foreign-key part of an ANY mapping.AttributeAccessor Names a persistent property access strategy (PropertyAccessStrategy
) 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.BAG
semantics.BatchSize Specifies a batch size for batch fetching of the annotated entity or collection.Cache Add caching strategy to a root entity or a collection.Cascade Apply a cascade strategy on an association.Check Specifies acheck
constraint to be included in the generated DDL.CollectionId Describe an identifier column for a bag.CollectionIdJavaType Form ofJavaType
for describing the id of an id-bag mappingCollectionIdJdbcType Form ofJdbcType
for describing the id of an id-bag mappingCollectionIdJdbcTypeCode Form ofJdbcTypeCode
for describing the id of an id-bag mappingCollectionIdMutability Form ofMutability
for describing the id of an id-bag mappingCollectionIdType Form ofType
for describing the id of an id-bag mappingCollectionType Names a custom collection type for a persistent collection.CollectionTypeRegistration Allows to register aUserCollectionType
to use as the default for the specified classification of collection.CollectionTypeRegistrations Repeatable container forCollectionTypeRegistration
ColumnDefault Specifies that a column has adefault
value specified in DDL.Columns Support an array of columns.ColumnTransformer Custom SQL expression used to read the value from and write a value to a column.ColumnTransformers Plural annotation for @ColumnTransformer.Comment Specifies a comment that will be included in generated DDL.CompositeType Applies a customCompositeUserType
for the attribute mapping.CompositeTypeRegistration Registers a custom composite user type implementation to be used for all references to a particularEmbeddable
.CompositeTypeRegistrations Grouping ofCompositeTypeRegistration
ConverterRegistration Registers anAttributeConverter
.ConverterRegistrations CreationTimestamp Marks a property as the creation timestamp of the containing entity.CurrentTimestamp Specifies that the databasecurrent_timestamp
function is used to generate values of the annotated attribute, based onCurrentTimestamp.timing()
.DialectOverride.Check Specializes aCheck
in a certain dialect.DialectOverride.Checks DialectOverride.ColumnDefault Specializes aColumnDefault
in a certain dialect.DialectOverride.ColumnDefaults DialectOverride.DiscriminatorFormula Specializes aDiscriminatorFormula
in a certain dialect.DialectOverride.DiscriminatorFormulas DialectOverride.FilterDefOverrides DialectOverride.FilterDefs SpecializesFilterDefs
in a certain dialect.DialectOverride.FilterOverrides DialectOverride.Filters SpecializesFilters
in a certain dialect.DialectOverride.Formula Specializes aFormula
in a certain dialect.DialectOverride.Formulas DialectOverride.GeneratedColumn Specializes aGeneratedColumn
in a certain dialect.DialectOverride.GeneratedColumns DialectOverride.JoinFormula Specializes aJoinFormula
in a certain dialect.DialectOverride.JoinFormulas DialectOverride.OrderBy Specializes anOrderBy
in 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 aWhere
in a certain dialect.DialectOverride.Wheres DiscriminatorFormula Specifies an expression written in native SQL as the discriminator for an entity inheritance hierarchy.DiscriminatorOptions Optional annotation to express Hibernate specific discriminator properties.DynamicInsert Specifies that SQLinsert
statements for the annotated entity are generated dynamically, and only include the columns to which a non-null value must be assigned.DynamicUpdate Specifies that SQLupdate
statements 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 ofEmbeddableInstantiatorRegistration
Fetch Specify the fetching strategy used for the annotated association.FetchProfile Define the fetching strategy profile.FetchProfile.FetchOverride Descriptor for a particular association override.FetchProfiles Collects together multiple fetch profiles.Filter Add filters to an entity or a target entity of a collection.FilterDef Filter definition.FilterDefs Array of filter definitions.FilterJoinTable Add filters to a join table collection.FilterJoinTables Add multiple@FilterJoinTable
to 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.1ForeignKey
annotationFormula 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 as
clause or equivalent, and that Hibernate should fetch the generated value from the database after each SQLINSERT
orUPDATE
.GeneratorType Deprecated. Most uses can be changed to useValueGenerationType
+AnnotationValueGeneration
GenericGenerator Generator annotation describing any kind of Hibernate generator in a generic (de-typed) manner.GenericGenerators Array of generic generator definitions.IdGeneratorType Meta-annotation used to mark another annotation as providing configuration for a customIdentifierGenerator
.Immutable Marks an entity, collection, or attribute as immutable.Index Deprecated. UsingIndex
instead.IndexColumn Deprecated. Prefer the standard JPAOrderColumn
annotation and the Hibernate specificListIndexBase
(for replacingIndexColumn.base()
).JavaType Specify an explicitBasicJavaType
to use for a particular column mapping.JavaTypeRegistration Registers the BasicJavaType to use for the givenJavaTypeRegistration.javaType()
JavaTypeRegistrations Grouping ofJavaTypeRegistration
See notes onJavaTypeRegistration
about using on packages versus use on classesJdbcType Specifies an explicitJdbcType
to 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 theJdbcTypeRegistry
JdbcTypeRegistrations Grouping ofJdbcTypeRegistration
See notes onJdbcTypeRegistration
about using on packages versus use on classesJoinColumnOrFormula Specifies one element of a composite join condition involving both formulas and columns.JoinColumnsOrFormulas Specifies a composite join condition involving one or more formulas and, optionally, one or more columns.JoinFormula Specifies a join condition based on an arbitrary native SQL formula instead of a column name.LazyCollection Define the lazy status of a collection.LazyGroup For use with bytecode-enhanced lazy-loading support.LazyToOne Define the laziness options available for aOneToOne
orManyToOne
) association.ListIndexBase Defines the start index value for a list index as stored on the database.ListIndexJavaType Form ofJavaType
for describing the column mapping for the index of a List or arrayListIndexJdbcType Form ofJdbcType
for describing the column mapping for the index of a List or arrayListIndexJdbcTypeCode Form ofJdbcTypeCode
for 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 Declares a many-valued association targeting one of several entity types, depending on a local discriminator column.MapKeyCompositeType Form ofCompositeType
for use with map-keysMapKeyJavaType Form ofJavaType
for describing the key of a MapMapKeyJdbcType Form ofJdbcType
for describing the key of a MapMapKeyJdbcTypeCode Form ofJdbcTypeCode
for describing the key of a MapMapKeyMutability Form ofMutability
for describing the key of a MapMapKeyType Form ofType
for use with map-keysMutability Used to specify aMutabilityPlan
for a basic value mapping.NamedNativeQueries A grouping of Hibernate-specificNamedNativeQuery
definitions.NamedNativeQuery ExtendsNamedNativeQuery
with Hibernate features.NamedQueries A grouping of Hibernate-specificNamedQuery
definitions.NamedQuery ExtendsNamedQuery
with Hibernate features.Nationalized Specifies that the annotated character data should be stored with nationalization support.NaturalId This specifies that a property is part of the natural id of the entity.NaturalIdCache Specifies that the natural id values associated with the annotated entity should be cached in the shared second-level cache.NotFound Indicates that an association maps to a foreign key column without a foreign key constraint, and which thus potentially violates referential integrity.OnDelete Strategy to use on collections, arrays and on joined subclasses delete.OptimisticLock Specifies whether updating the annotated attribute should trigger an increment to theversion
of the entity instance.OptimisticLocking Used to define the style of optimistic locking to be applied to an entity.OrderBy Order a collection using an expression written in native SQL.ParamDef Details about a parameter defined in a FilterDef.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).Persister Specify a custom persister.Polymorphism Used to define the type of polymorphism Hibernate will apply to entity hierarchies.Proxy Lazy and proxy configuration of a particular class.RowId Specifies that an Oracle-stylerowid
should be used in SQLupdate
statements for an entity, instead of the primary key.SelectBeforeUpdate Specifies that the current persistent state of a detached entity instance should be fetched from the database when the entity is reattached usingSession.update(Object)
.SortComparator SortNatural Source Optional annotation in conjunction withVersion
and timestamp version properties indicating the source of the timestamp value.SQLDelete Custom SQL statement for delete of an entity/collection.SQLDeleteAll Custom SQL statement for delete of all of a collection's elements.SqlFragmentAlias Describe aliases for filters.SQLInsert Custom SQL statement for insertion of an entity/collection.SQLUpdate Custom SQL statement for update of an entity/collection.Subselect Maps an immutable and read-only entity to a given SQLselect
expression.Synchronize Ensures 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
, orSecondaryTable
annotation.Tables A grouping of tables.Target Define an explicit target, avoiding reflection and generics resolving.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.TimeZoneStorage Specifies how the time zone information of a persistent property or field should be persisted.Type Specifies a customUserType
for the annotated attribute mapping.UpdateTimestamp Marks a property as the update timestamp of the containing entity.UuidGenerator Specifies that an entity identifier is generated as an RFC 4122 UUID.ValueGenerationType Marks an annotation type as a generator annotation type.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 table
of a collection.