Annotation Interface Embeddable
The annotated type must:
- be a non-
abstract
, non-final
top-level class or static inner class, or a Java record type, - have a
public
orprotected
constructor with no parameters, unless it is a record type, and - have no
final
methods or persistent instance variables.
An enum or interface may not be designated as an embeddable type.
An embeddable class does not have its own table. Instead, the state of an instance is stored in the table or tables mapped by the owning entity.
The persistent fields and properties of an embeddable class are mapped using the same mapping annotations used to map entity classes, and may themselves hold instances of embeddable types. An embeddable class may even declare an association from its owning entity to another entity.
However, an embeddable class may not have a field or
property annotated Id
or EmbeddedId
.
Fields or properties of an embeddable 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 embeddable class which is
not persistent.
Example 1:
Example 2:
Example 3:
- Since:
- 1.0
- See Also: