JPA Components Annotations

You can use Jakarta Persistence (JPA) annotations to mark classes as persistent and to configure their behavior.

Persistent type definitions

Use these annotations to assign a role to a persistent class:

Marks the class as an entity. Entities are persistent domain objects with a unique identity (primary key) and their own lifecycle.

Marks the class as embeddable. Instances are stored as part of an owning entity and share its identity; they have no persistent identity of their own.

Marks the class as a mapped superclass. Its persistent attributes (fields and properties) and their settings are inherited by entity subclasses, but the mapped superclass is not persistent on its own.

For details, see the Persistent Classes chapter in the ObjectDB manual.

Access modes and cache

JPA and ObjectDB can access persistent state directly (field access) or through getters and setters (property access). Use these annotations to configure the access type:

Sets the access type (FIELD or PROPERTY) for an entity, mapped superclass, or embeddable class.

Enum used with @Access to choose between FIELD and PROPERTY access.

Entity and mapped superclass instances can also be configured for second-level caching:

Specifies whether the entity is eligible for the second-level cache. Set to true or false to override the global cache mode.

Helper classes

The following annotations apply to helper classes:

Specifies a composite primary key class mapped to multiple fields or properties of the entity. This allows the entity to use a flat ID class for lookups. For more information, see the Primary Key section in the ObjectDB manual.

Specifies that the class is a static metamodel class that represents the attributes of the corresponding entity, typically for use with the Criteria API.