Module jakarta.persistence
Package jakarta.persistence
Jakarta Persistence is the API for the management for persistence and object/relational mapping.
-
Interface Summary Interface Description AttributeConverter<X,Y> Interface implemented by custom attribute converters.AttributeNode<T> Represents an attribute node of an entity graph.Cache Interface used to interact with the second-level cache.ConnectionConsumer<C> An executable action which makes use of a native database connection.ConnectionFunction<C,T> A function which makes use of a native database connection to compute a result.EntityGraph<T> This type represents the root of an entity graph that will be used as a template to define the attribute nodes and boundaries of a graph of entities and entity relationships.EntityManager Interface used to interact with the persistence context.EntityManagerFactory Interface used to interact with the persistence unit, and to create new instances ofEntityManager
.EntityTransaction Interface used to control transactions on resource-local entity managers.FindOption An option influencing the behavior ofEntityManager.find(java.lang.Class<T>, java.lang.Object)
.Graph<T> Declares operations common toEntityGraph
andSubgraph
.LockOption An option influencing the behavior ofEntityManager.lock(java.lang.Object, jakarta.persistence.LockModeType)
.Parameter<T> Type for query parameter objects.PersistenceUnitUtil Utility interface between the application and the persistence provider managing the persistence unit.PersistenceUtil Utility interface between the application and the persistence provider(s).Query Interface used to control query execution.RefreshOption An option influencing the behavior ofEntityManager.refresh(java.lang.Object)
.SchemaManager Allows programmatic schema creation, schema validation, data cleanup, and schema cleanup for entities belonging to a certain persistence unit.StoredProcedureQuery Interface used to control stored procedure query execution.Subgraph<T> This type represents a subgraph for an attribute node that corresponds to a managed type.Tuple Interface for extracting the elements of a query result tuple.TupleElement<X> TheTupleElement
interface defines an element that is returned in a query result tuple.TypedQuery<X> Interface used to control the execution of typed queries.TypedQueryReference<R> A reference to a named query declared via theNamedQuery
orNamedNativeQuery
annotations. -
Class Summary Class Description Persistence Bootstrap class used to obtain anEntityManagerFactory
in Java SE environments.Persistence.PersistenceUtilImpl Implementation of thePersistenceUtil
interfacePersistenceConfiguration Represents a configuration of a persistence unit, allowing programmatic creation of anEntityManagerFactory
.Timeout Specifies a timeout for a database request. -
Enum Summary Enum Description AccessType Used with theAccess
annotation to specify an access type to be applied to an entity class, mapped superclass, or embeddable class, or to a specific attribute of such a class.CacheRetrieveMode Specifies how theEntityManager
interacts with the second-level cache when data is read from the database via theEntityManager.find(java.lang.Class<T>, java.lang.Object)
methods and execution of queries.CacheStoreMode Specifies how theEntityManager
interacts with the second-level cache when data is read from the database and when data is written to the database.CascadeType Defines the set of cascadable operations that are propagated to the associated entity.ConstraintMode Used to control the application of a constraint.DiscriminatorType Defines supported types of the discriminator column.EnumType Enumerates available options for mapping enumerated types.FetchType Defines strategies for fetching data from the database.FlushModeType Enumerates flush modes recognized by theEntityManager
.GenerationType Enumerates the defined primary key generation strategies.InheritanceType Enumerated the options for mapping entity inheritance.LockModeType Enumerates the kinds of optimistic or pessimistic lock which may be obtained on an entity instance.ParameterMode Specifies the mode of a parameter of a stored procedure query.PersistenceContextType Specifies whether a transaction-scoped or extended persistence context is to be used inPersistenceContext
.PersistenceUnitTransactionType Enumerates the possible approaches to transaction management in Jakarta Persistence.PessimisticLockScope Defines the values of thejakarta.persistence.lock.scope
property for pessimistic locking.SharedCacheMode Specifies how the provider must use a second-level cache for the persistence unit.SynchronizationType Specifies whether the persistence context is always automatically synchronized with the current transaction or whether the persistence context must be explicitly joined to the current transaction by means of theEntityManager.joinTransaction()
method.TemporalType Deprecated. Newly-written code should use the date/time types defined injava.time
.ValidationMode The validation mode to be used by the provider for the persistence unit. -
Exception Summary Exception Description EntityExistsException Thrown by the persistence provider whenEntityManager.persist(Object)
is called and the entity already exists.EntityNotFoundException Thrown by the persistence provider when an entity reference obtained byEntityManager.getReference
is accessed but the entity does not exist.LockTimeoutException Thrown by the persistence provider when a pessimistic locking conflict occurs that does not result in transaction rollback.NonUniqueResultException Thrown by the persistence provider whenQuery.getSingleResult()
orTypedQuery.getSingleResult()
is executed and there is more than one result from the query.NoResultException Thrown by the persistence provider whenQuery.getSingleResult()
orTypedQuery.getSingleResult()
is executed and there is no result to return.OptimisticLockException Thrown by the persistence provider when an optimistic locking conflict occurs.PersistenceException Thrown by the persistence provider when a problem occurs.PessimisticLockException Thrown by the persistence provider when a pessimistic locking conflict occurs.QueryTimeoutException Thrown by the persistence provider when a query times out and only the statement is rolled back.RollbackException Thrown by the persistence provider whenEntityTransaction.commit()
fails.SchemaValidationException Thrown whenschema validation
fails.TransactionRequiredException Thrown by the persistence provider when a transaction is required but is not active. -
Annotation Types Summary Annotation Type Description Access Used to specify an access type to be applied to an entity class, mapped superclass, or embeddable class, or to a specific attribute of such a class.AssociationOverride Used to override a mapping for an entity relationship.AssociationOverrides Used to override mappings of multiple relationship properties or fields.AttributeOverride Used to override the mapping of aBasic
(whether explicit or default) property or field orId
property or field.AttributeOverrides Used to override mappings of multiple properties or fields.Basic The simplest type of mapping of a persistent field or property to a single database column.Cacheable Specifies whether an entity should be cached, if caching is enabled, and when the value of thepersistence.xml
caching element isSharedCacheMode.ENABLE_SELECTIVE
orSharedCacheMode.DISABLE_SELECTIVE
.CheckConstraint Used to specify a SQL check constraint on a column or table when schema generation is in effect.CollectionTable Specifies the table that is used for the mapping of collections of basic or embeddable types.Column Specifies the column mapped by the annotated persistent property or field.ColumnResult Used in conjunction with theSqlResultSetMapping
,NamedNativeQuery
, orConstructorResult
annotation to map a column of the SELECT list of a SQL query.ConstructorResult Used in conjunction with theSqlResultSetMapping
orNamedNativeQuery
annotation to map the SELECT clause of a SQL query to a constructor.Convert Specifies how the values of a field or property are converted to a basic type, enabling a converter definedautoApply=false
, overriding the use of a converter definedautoApply=true
, or overriding the use of a converter specified by a field or property of an embedded type or inherited mapped superclass.Converter Declares that the annotated class is a converter and specifies whether the converter is automatically applied.Converts Used to groupConvert
annotations.DiscriminatorColumn DiscriminatorValue Specifies the value of the discriminator column for the annotated entity type.ElementCollection Declares a collection of instances of a basic type or embeddable class.Embeddable Declares a type whose instances are stored as an intrinsic part of an owning entity, sharing the identity of the entity.Embedded Declares a persistent field or property of an entity whose value is an instance of an embeddable class.EmbeddedId Specifies that the annotated persistent field or property of an entity class or mapped superclass is the composite primary key of the entity.Entity Declares that the annotated class is an entity.EntityListeners Specifies the callback listener classes to be used for an entity or mapped superclass.EntityResult Used in conjunction with theSqlResultSetMapping
orNamedNativeQuery
annotation to map the SELECT clause of a SQL query to an entity result.Enumerated Specifies that a persistent property or field should be persisted as an enumerated type.EnumeratedValue Specifies that an annotated field of a Javaenum
type is the source of database column values for an enumerated mapping.ExcludeDefaultListeners Specifies that the invocation of default listeners is to be excluded for the entity class (or mapped superclass) and its subclasses.ExcludeSuperclassListeners Specifies that the invocation of superclass listeners is to be excluded for the entity class (or mapped superclass) and its subclasses.FieldResult Used in conjunction with theEntityResult
annotation to map columns specified in the SELECT list of a SQL query to the properties or fields of an entity class.ForeignKey Specifies the handling of foreign key constraints when schema generation is in effect.GeneratedValue Specifies a generation strategy for generated primary keys.Id Identifies the primary key of an entity.IdClass Specifies a composite primary key type whose fields or properties map to the identifier fields or properties of the annotated entity class.Index Used in schema generation to specify creation of an index.Inheritance Specifies the inheritance mapping strategy for the entity class hierarchy which descends from the annotated entity class.JoinColumn Specifies a column for joining an entity association or element collection.JoinColumns Specifies the mapping for composite foreign keys.JoinTable Specifies the mapping of an association to an intermediate join table.Lob Specifies that the annotated persistent property or field should be persisted as a large object to a database-native large object (LOB) type.ManyToMany Specifies a many-valued association with many-to-many multiplicity, mapping to an intermediate table called the join table.ManyToOne Specifies a single-valued association to another entity class that has many-to-one multiplicity.MapKey Specifies the map key for associations of typeMap
when the map key is itself the primary key or a persistent field or property of the entity that is the value of the map.MapKeyClass Specifies the type of the map key for associations of typeMap
.MapKeyColumn Specifies the mapping for the key column of a map whose map key is a basic type.MapKeyEnumerated Specifies the enum type for a map key whose basic type is an enumerated type.MapKeyJoinColumn Specifies a mapping to an entity that is a map key.MapKeyJoinColumns Supports composite map keys that reference entities.MapKeyTemporal Deprecated. Newly-written code should use the date/time types defined injava.time
.MappedSuperclass Declares a class which is not itself an entity, but whose mappings are inherited by the entities which extend it.MapsId Designates aManyToOne
orOneToOne
relationship attribute that provides the mapping for anEmbeddedId
primary key, an attribute within anEmbeddedId
primary key, or a simple primary key of the parent entity.NamedAttributeNode ANamedAttributeNode
is a member element of aNamedEntityGraph
.NamedEntityGraph Defines a named entity graph.NamedEntityGraphs Used to groupNamedEntityGraph
annotations.NamedNativeQueries Declares multiple native SQL named queries.NamedNativeQuery Declares a named native SQL query and, optionally, the mapping of the result of the native SQL query.NamedQueries Declares multiple named Jakarta Persistence query language queries.NamedQuery Declares a named query written in the Jakarta Persistence query language.NamedStoredProcedureQueries Specifies multiple named stored procedure queries.NamedStoredProcedureQuery Declares and names a stored procedure, its parameters, and its result type.NamedSubgraph ANamedSubgraph
is a member element of aNamedEntityGraph
.OneToMany Specifies a many-valued association with one-to-many multiplicity.OneToOne Specifies a single-valued association to another entity class that has one-to-one multiplicity.OrderBy Specifies the ordering of the elements of a collection-valued association or element collection at the point when the association or collection is retrieved.OrderColumn Specifies a column that is used to maintain the persistent order of a list.PersistenceContext Expresses a dependency on a container-managedEntityManager
and its associated persistence context.PersistenceContexts Declares one or morePersistenceContext
annotations.PersistenceProperty Describes a single container or persistence provider property.PersistenceUnit Expresses a dependency on anEntityManagerFactory
and its associated persistence unit.PersistenceUnits Declares one or morePersistenceUnit
annotations.PostLoad Specifies a callback method for the corresponding lifecycle event.PostPersist Specifies a callback method for the corresponding lifecycle event.PostRemove Specifies a callback method for the corresponding lifecycle event.PostUpdate Specifies a callback method for the corresponding lifecycle event.PrePersist Specifies a callback method for the corresponding lifecycle event.PreRemove Specifies a callback method for the corresponding lifecycle event.PreUpdate Specifies a callback method for the corresponding lifecycle event.PrimaryKeyJoinColumn Specifies a primary key column that is used as a foreign key to join to another table.PrimaryKeyJoinColumns GroupsPrimaryKeyJoinColumn
annotations.QueryHint Used to supply a query property or hint to theNamedQuery
orNamedNativeQuery
annotation.SecondaryTable Specifies a secondary table for the annotated entity class.SecondaryTables Specifies multiple secondary tables for an entity.SequenceGenerator Defines a primary key generator that may be referenced by name when a generator element is specified for theGeneratedValue
annotation.SequenceGenerators Used to groupSequenceGenerator
annotations.SqlResultSetMapping Specifies a mapping of the columns of a result set of a native SQL query or stored procedure.SqlResultSetMappings Used to define one or moreSqlResultSetMapping
annotations.StoredProcedureParameter Declares a parameter of a named stored procedure query.Table Specifies the primary table mapped by the annotated entity type.TableGenerator Defines a primary key generator that may be referenced by name when a generator element is specified for theGeneratedValue
annotation.TableGenerators Used to groupTableGenerator
annotations.Temporal Deprecated. Newly-written code should use the date/time types defined injava.time
.Transient Specifies that the annotated property or field is not persistent.UniqueConstraint Specifies that a unique constraint is to be included in the generated DDL for a primary or secondary table.Version Declares the version field or property of an entity class, which is used to detect optimistic lock failures, ensuring the integrity of optimistic transactions.