final top-level class or static inner class,
public or protected constructor with no
parameters, and
final methods or persistent instance variables.
An enum, record, or interface may not be designated as an entity.
An entity has a primary table, mapped using the Table
annotation, and may have one or more secondary tables, mapped using
the SecondaryTable annotation.
An entity class holds state, represented as persistent fields and properties:
Every entity class must have at least one field or property
annotated Id or EmbeddedId holding the primary key
of the entity. An entity class may optionally have a field or
property annotated Version, which holds a value used to
detect optimistic lock failure.
Fields or properties of an entity class are persistent by default.
The Transient annotation or the Java transient keyword
must be used to explicitly declare any field or property of an entity
which is not persistent.
The entity access type determines whether
the persistence provider accesses the state of the entity using getter
and setter methods, or via direct field access. It is almost never
necessary to explicitly specify an AccessType, since the
default access type for an entity is determined by the placement of
mapping annotations on the entity class.
Apart from its persistent fields and properties, an entity class
may declare callback methods using PrePersist, PreUpdate,
PreRemove, PostPersist, PostUpdate, and/or
PostRemove.
| Modifier and Type | Method and Description |
|---|---|
| public String |
| name | back to summary |
|---|---|
| public String name() (Optional) The entity name. Defaults to the unqualified name of the entity class. This name is used to refer to the entity in queries. The name must not be a reserved literal in the Jakarta Persistence query language. | |