JPA Attributes Annotations
Jakarta Persistence (JPA) annotations define how entity attributes (fields and properties) are managed. These annotations control data persistence behavior, including fetching strategies, relationship types, and data storage formats.
General field mapping
Configure standard state mapping behavior using the following annotations:
Sets a field or property of a basic attribute (e.g., primitives, wrappers, Strings). While optional for supported types, it allows configuration of fetch strategies (Lazy/Eager) and nullability.
Specifies a persistent field or property as an embedded attribute. The embedded state is stored in the same table as the owning entity.
Specifies a collection field or property as an attribute containing a collection of embedded objects. This is used for "one-to-many" relationships where the target is not an entity.
Specifies that the field or property is not persistent. The persistence provider ignores transient fields when saving or retrieving the entity.
Identity and versioning mapping
Annotations used to define primary keys and concurrency control:
Specifies the simple primary key of an entity.
Specifies a composite primary key that is an instance of an embeddable class.
Specifies the version field or property of an entity, which is used to perform optimistic locking checks.
Enum mapping
Configure how Java enumerated types are persisted and used as map keys:
Specifies whether an enum should be persisted by its ordinal value or its string name.
Specifies that the key of a map field or property is an enumerated type.
Defines the constants used to specify the storage format for enumerated types.
Temporal mapping
Map legacy date and calendar types to specific SQL temporal formats (modern java.time types are mapped automatically):
Specifies the database SQL type for a persistent field or property of type java.util.Date or java.util.Calendar.
Specifies the database SQL type for a map key of type java.util.Date or java.util.Calendar.
An enumeration defining the SQL type mapping: DATE, TIME, or TIMESTAMP.
For more details, see the Persistent Classes chapter in the ObjectDB manual.