Top Description Methods
jakarta.persistence

public @Interface Entity

extends Annotation
Annotations
@Documented
@Target:TYPE
@Retention:RUNTIME
Imports
java.lang.annotation.Target, .Retention, .Documented

Declares that the annotated class is an entity. The annotated entity class must:

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.

Since
1.0

Method Summary

Modifier and TypeMethod and Description
public String
name()

(Optional) The entity name.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

nameback 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.