Top Description Interfaces Annotations Classes Enums
module jakarta.persistence

Package jakarta.persistence


Jakarta Persistence is the API for the management for persistence and object/relational mapping.

Interface Summary

Modifier and TypeInterface and Description
public interface
AttributeConverter<
the target type, that is, the type of the entity attribute
X
,
a basic type representing the type of the database column
Y
>

Interface implemented by custom attribute converters.

public interface
AttributeNode<
The type of the attribute.
T
>

Represents an attribute node of an entity graph.

public interface
Cache

Interface used to interact with the second-level cache.

public interface
ConnectionConsumer<
the connection type, usually java.sql.Connection
C
>

An executable action which makes use of a native database connection.

public interface
ConnectionFunction<
the connection type, usually java.sql.Connection
C
, T>

A function which makes use of a native database connection to compute a result.

public interface
EntityGraph<
The type of the root entity.
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.

public interface
EntityManager

Interface used to interact with the persistence context.

public interface
EntityManagerFactory

Interface used to interact with the persistence unit, and to create new instances of EntityManager.

public interface
EntityTransaction

Interface used to control transactions on resource-local entity managers.

public interface
FindOption

An option influencing the behavior of EntityManager#find.

public interface
Graph<T>

Declares operations common to EntityGraph and Subgraph.

public interface
LockOption

An option influencing the behavior of EntityManager#lock.

public interface
Parameter<
the type of the parameter
T
>

Type for query parameter objects.

public interface
PersistenceUnitUtil

Utility interface between the application and the persistence provider managing the persistence unit.

public interface
PersistenceUtil

Utility interface between the application and the persistence provider(s).

public interface
Query

Interface used to control query execution.

public interface
RefreshOption

An option influencing the behavior of EntityManager#refresh.

public interface
SchemaManager

Allows programmatic schema creation, schema validation, data cleanup, and schema cleanup for entities belonging to a certain persistence unit.

public interface
StoredProcedureQuery

Interface used to control stored procedure query execution.

public interface
Subgraph<
The type of the attribute.
T
>

This type represents a subgraph for an attribute node that corresponds to a managed type.

public interface
Tuple

Interface for extracting the elements of a query result tuple.

public interface
TupleElement<
the type of the element
X
>

The TupleElement interface defines an element that is returned in a query result tuple.

public interface
TypedQuery<
query result type
X
>

Interface used to control the execution of typed queries.

public interface
TypedQueryReference<
an upper bound on the result type of the query
R
>

A reference to a named query declared via the NamedQuery or NamedNativeQuery annotations.

Annotation Summary

Modifier and TypeAnnotation and Description
public @interface
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.

public @interface
AssociationOverride

Used to override a mapping for an entity relationship.

public @interface
AssociationOverrides

Used to override mappings of multiple relationship properties or fields.

public @interface
AttributeOverride

Used to override the mapping of a Basic (whether explicit or default) property or field or Id property or field.

public @interface
AttributeOverrides

Used to override mappings of multiple properties or fields.

public @interface
Basic

The simplest type of mapping of a persistent field or property to a single database column.

public @interface
Cacheable

Specifies whether an entity should be cached, if caching is enabled, and when the value of the persistence.xml caching element is SharedCacheMode#ENABLE_SELECTIVE or SharedCacheMode#DISABLE_SELECTIVE.

public @interface
CheckConstraint

Used to specify a SQL check constraint on a column or table when schema generation is in effect.

public @interface
CollectionTable

Specifies the table that is used for the mapping of collections of basic or embeddable types.

public @interface
Column

Specifies the column mapped by the annotated persistent property or field.

public @interface
ColumnResult

Used in conjunction with the SqlResultSetMapping, NamedNativeQuery, or ConstructorResult annotation to map a column of the SELECT list of a SQL query.

public @interface
ConstructorResult

Used in conjunction with the SqlResultSetMapping or NamedNativeQuery annotation to map the SELECT clause of a SQL query to a constructor.

public @interface
Convert

Specifies how the values of a field or property are converted to a basic type, enabling a converter defined autoApply=false, overriding the use of a converter defined autoApply=true, or overriding the use of a converter specified by a field or property of an embedded type or inherited mapped superclass.

public @interface
Converter

Declares that the annotated class is a converter and specifies whether the converter is automatically applied.

public @interface
Converts

Used to group Convert annotations.

public @interface
DiscriminatorColumn

Specifies the discriminator column for the SINGLE_TABLE and JOINED inheritance mapping strategies.

public @interface
DiscriminatorValue

Specifies the value of the discriminator column for the annotated entity type.

public @interface
ElementCollection

Declares a collection of instances of a basic type or embeddable class.

public @interface
Embeddable

Declares a type whose instances are stored as an intrinsic part of an owning entity, sharing the identity of the entity.

public @interface
Embedded

Declares a persistent field or property of an entity whose value is an instance of an embeddable class.

public @interface
EmbeddedId

Specifies that the annotated persistent field or property of an entity class or mapped superclass is the composite primary key of the entity.

public @interface
Entity

Declares that the annotated class is an entity.

public @interface
EntityListeners

Specifies the callback listener classes to be used for an entity or mapped superclass.

public @interface
EntityResult

Used in conjunction with the SqlResultSetMapping or NamedNativeQuery annotation to map the SELECT clause of a SQL query to an entity result.

public @interface
Enumerated

Specifies that a persistent property or field should be persisted as an enumerated type.

public @interface
EnumeratedValue

Specifies that an annotated field of a Java enum type is the source of database column values for an enumerated mapping.

public @interface
ExcludeDefaultListeners

Specifies that the invocation of default listeners is to be excluded for the entity class (or mapped superclass) and its subclasses.

public @interface
ExcludeSuperclassListeners

Specifies that the invocation of superclass listeners is to be excluded for the entity class (or mapped superclass) and its subclasses.

public @interface
FieldResult

Used in conjunction with the EntityResult annotation to map columns specified in the SELECT list of a SQL query to the properties or fields of an entity class.

public @interface
ForeignKey

Specifies the handling of foreign key constraints when schema generation is in effect.

public @interface
GeneratedValue

Specifies a generation strategy for generated primary keys.

public @interface
Id

Identifies the primary key of an entity.

public @interface
IdClass

Specifies a composite primary key type whose fields or properties map to the identifier fields or properties of the annotated entity class.

public @interface
Index

Used in schema generation to specify creation of an index.

public @interface
Inheritance

Specifies the inheritance mapping strategy for the entity class hierarchy which descends from the annotated entity class.

public @interface
JoinColumn

Specifies a column for joining an entity association or element collection.

public @interface
JoinColumns

Specifies the mapping for composite foreign keys.

public @interface
JoinTable

Specifies the mapping of an association to an intermediate join table.

public @interface
Lob

Specifies that the annotated persistent property or field should be persisted as a large object to a database-native large object (LOB) type.

public @interface
ManyToMany

Specifies a many-valued association with many-to-many multiplicity, mapping to an intermediate table called the join table.

public @interface
ManyToOne

Specifies a single-valued association to another entity class that has many-to-one multiplicity.

public @interface
MapKey

Specifies the map key for associations of type java.util.Map 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.

public @interface
MapKeyClass

Specifies the type of the map key for associations of type java.util.Map.

public @interface
MapKeyColumn

Specifies the mapping for the key column of a map whose map key is a basic type.

public @interface
MapKeyEnumerated

Specifies the enum type for a map key whose basic type is an enumerated type.

public @interface
MapKeyJoinColumn

Specifies a mapping to an entity that is a map key.

public @interface
MapKeyJoinColumns

Supports composite map keys that reference entities.

public @interface
MapKeyTemporal

Deprecated since 3.2. Newly-written code should use the date/time types defined in java.time.
This annotation must be specified for persistent map keys of type java.util.Date and java.util.Calendar.
public @interface
MappedSuperclass

Declares a class which is not itself an entity, but whose mappings are inherited by the entities which extend it.

public @interface
MapsId

Designates a ManyToOne or OneToOne relationship attribute that provides the mapping for an EmbeddedId primary key, an attribute within an EmbeddedId primary key, or a simple primary key of the parent entity.

public @interface
NamedAttributeNode

A NamedAttributeNode is a member element of a NamedEntityGraph.

public @interface
public @interface
NamedEntityGraphs

Used to group NamedEntityGraph annotations.

public @interface
NamedNativeQueries

Declares multiple native SQL named queries.

public @interface
NamedNativeQuery

Declares a named native SQL query and, optionally, the mapping of the result of the native SQL query.

public @interface
NamedQueries

Declares multiple named Jakarta Persistence query language queries.

public @interface
NamedQuery

Declares a named query written in the Jakarta Persistence query language.

public @interface
NamedStoredProcedureQueries

Specifies multiple named stored procedure queries.

public @interface
NamedStoredProcedureQuery

Declares and names a stored procedure, its parameters, and its result type.

public @interface
NamedSubgraph

A NamedSubgraph is a member element of a NamedEntityGraph.

public @interface
OneToMany

Specifies a many-valued association with one-to-many multiplicity.

public @interface
OneToOne

Specifies a single-valued association to another entity class that has one-to-one multiplicity.

public @interface
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.

public @interface
OrderColumn

Specifies a column that is used to maintain the persistent order of a list.

public @interface
PersistenceContext

Expresses a dependency on a container-managed EntityManager and its associated persistence context.

public @interface
PersistenceContexts

Declares one or more PersistenceContext annotations.

public @interface
PersistenceProperty

Describes a single container or persistence provider property.

public @interface
PersistenceUnit

Expresses a dependency on an EntityManagerFactory and its associated persistence unit.

public @interface
PersistenceUnits

Declares one or more PersistenceUnit annotations.

public @interface
PostLoad

Specifies a callback method for the corresponding lifecycle event.

public @interface
PostPersist

Specifies a callback method for the corresponding lifecycle event.

public @interface
PostRemove

Specifies a callback method for the corresponding lifecycle event.

public @interface
PostUpdate

Specifies a callback method for the corresponding lifecycle event.

public @interface
PrePersist

Specifies a callback method for the corresponding lifecycle event.

public @interface
PreRemove

Specifies a callback method for the corresponding lifecycle event.

public @interface
PreUpdate

Specifies a callback method for the corresponding lifecycle event.

public @interface
PrimaryKeyJoinColumn

Specifies a primary key column that is used as a foreign key to join to another table.

public @interface
public @interface
QueryHint

Used to supply a query property or hint to the NamedQuery or NamedNativeQuery annotation.

public @interface
SecondaryTable

Specifies a secondary table for the annotated entity class.

public @interface
SecondaryTables

Specifies multiple secondary tables for an entity.

public @interface
SequenceGenerator

Defines a primary key generator that may be referenced by name when a generator element is specified for the GeneratedValue annotation.

public @interface
SequenceGenerators

Used to group SequenceGenerator annotations.

public @interface
SqlResultSetMapping

Specifies a mapping of the columns of a result set of a native SQL query or stored procedure.

public @interface
SqlResultSetMappings

Used to define one or more SqlResultSetMapping annotations.

public @interface
StoredProcedureParameter

Declares a parameter of a named stored procedure query.

public @interface
Table

Specifies the primary table mapped by the annotated entity type.

public @interface
TableGenerator

Defines a primary key generator that may be referenced by name when a generator element is specified for the GeneratedValue annotation.

public @interface
TableGenerators

Used to group TableGenerator annotations.

public @interface
Temporal

Deprecated since 3.2. Newly-written code should use the date/time types defined in java.time.
This annotation must be specified for persistent fields or properties of type java.util.Date and java.util.Calendar.
public @interface
Transient

Specifies that the annotated property or field is not persistent.

public @interface
UniqueConstraint

Specifies that a unique constraint is to be included in the generated DDL for a primary or secondary table.

public @interface
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.

Class Summary

Modifier and TypeClass and Description
public class
EntityExistsException

Thrown by the persistence provider when EntityManager#persist(Object) is called and the entity already exists.

public class
EntityNotFoundException

Thrown by the persistence provider when an entity reference obtained by EntityManager.getReference is accessed but the entity does not exist.

public class
LockTimeoutException

Thrown by the persistence provider when a pessimistic locking conflict occurs that does not result in transaction rollback.

public class
NonUniqueResultException

Thrown by the persistence provider when Query#getSingleResult() or TypedQuery#getSingleResult() is executed and there is more than one result from the query.

public class
NoResultException

Thrown by the persistence provider when Query#getSingleResult() or TypedQuery#getSingleResult() is executed and there is no result to return.

public class
OptimisticLockException

Thrown by the persistence provider when an optimistic locking conflict occurs.

public class
Persistence

Bootstrap class used to obtain an EntityManagerFactory in Java SE environments.

public class
PersistenceConfiguration

Represents a configuration of a persistence unit, allowing programmatic creation of an EntityManagerFactory.

public class
PersistenceException

Thrown by the persistence provider when a problem occurs.

public class
PessimisticLockException

Thrown by the persistence provider when a pessimistic locking conflict occurs.

public class
QueryTimeoutException

Thrown by the persistence provider when a query times out and only the statement is rolled back.

public class
RollbackException

Thrown by the persistence provider when EntityTransaction#commit() fails.

public class
public class
Timeout

Specifies a timeout for a database request.

public class
TransactionRequiredException

Thrown by the persistence provider when a transaction is required but is not active.

Enum Summary

Modifier and TypeEnum and Description
public enum
AccessType

Used with the Access 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.

public enum
CacheRetrieveMode

Specifies how the EntityManager interacts with the second-level cache when data is read from the database via the EntityManager#find methods and execution of queries.

public enum
CacheStoreMode

Specifies how the EntityManager interacts with the second-level cache when data is read from the database and when data is written to the database.

public enum
CascadeType

Defines the set of cascadable operations that are propagated to the associated entity.

public enum
ConstraintMode

Used to control the application of a constraint.

public enum
DiscriminatorType

Defines supported types of the discriminator column.

public enum
EnumType

Enumerates available options for mapping enumerated types.

public enum
FetchType

Defines strategies for fetching data from the database.

public enum
FlushModeType

Enumerates flush modes recognized by the EntityManager.

public enum
GenerationType

Enumerates the defined primary key generation strategies.

public enum
InheritanceType

Enumerated the options for mapping entity inheritance.

public enum
LockModeType

Enumerates the kinds of optimistic or pessimistic lock which may be obtained on an entity instance.

public enum
ParameterMode

Specifies the mode of a parameter of a stored procedure query.

public enum
PersistenceContextType

Specifies whether a transaction-scoped or extended persistence context is to be used in PersistenceContext.

public enum
PersistenceUnitTransactionType

Enumerates the possible approaches to transaction management in Jakarta Persistence.

public enum
PessimisticLockScope

Defines the values of the jakarta.persistence.lock.scope property for pessimistic locking.

public enum
SharedCacheMode

Specifies how the provider must use a second-level cache for the persistence unit.

public enum
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 the EntityManager#joinTransaction() method.

public enum
TemporalType

Deprecated since 3.2. Newly-written code should use the date/time types defined in java.time.
Type used to indicate a specific mapping of java.util.Date or java.util.Calendar.
public enum
ValidationMode

The validation mode to be used by the provider for the persistence unit.