Enum Class Embeddable.EmbeddableType
- All Implemented Interfaces:
Serializable, Comparable<Embeddable.EmbeddableType>, Constable
- Enclosing class:
Embeddable
FLAT: The fields of the embeddable class are embedded directly into the data structure of the parent entity or embeddable, without creating a nested structure in the database.GROUPING: The fields of the embeddable class are stored in a structured type, such as a user-defined type (UDT), where the fields are grouped together under a single object or nested structure within the parent entity.
The FLAT strategy ensures that the embeddable class fields are directly mapped to the database schema of the parent entity, whereas the GROUPING strategy results in the embeddable fields being treated as a distinct structure that may be stored in a separate sub-schema (like a UDT or nested document), depending on the NoSQL database used.
While the FLAT strategy is guaranteed to be supported by all Jakarta NoSQL implementations, the support for the GROUPING strategy
may vary between NoSQL databases. If a NoSQL database does not support it, invoking operations requiring the GROUPING strategy
may result in an UnsupportedOperationException. Additionally, if a database requires specific configurations, such as
the Column.udt() attribute, and those configurations are not met, a MappingException may be thrown.
Example use case of the enum values:
@Embeddable(EmbeddableType.FLAT)
public class Address {
@Column
private String street;
@Column
private String city;
}
@Embeddable(EmbeddableType.GROUPING)
public class Address {
@Column
private String street;
@Column
private String city;
}
- Since:
- 1.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic Embeddable.EmbeddableTypeReturns the enum constant of this class with the specified name.static Embeddable.EmbeddableType[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
FLAT
Fields of the embeddable class are embedded directly into the data structure of the parent entity or embeddable.This is the default behavior when using
Embeddablewithout specifying a type.Example:
@Entity public class Person { @Id private String id; @Column private String name; @Column private Address address; } @Embeddable public class Address { @Column private String street; @Column private String city; }Illustrative structure with
FLATembedding:{ "id": "p1", "name": "Ada", "street": "123 Main St", "city": "Leiria" }This representation illustrates how the embedded fields are flattened into the parent. Actual persistence formats may vary depending on the NoSQL database provider.
-
GROUPING
Fields of the embeddable class are stored in a grouped structure, such as a user-defined type (UDT) or embedded document.This mode is used to encapsulate the embeddable fields under a single object inside the parent structure.
Example:
@Entity public class Person { @Id private String id; @Column private String name; @Column private Address address; } @Embeddable(EmbeddableType.GROUPING) public class Address { @Column private String street; @Column private String city; }Illustrative structure with
GROUPINGembedding:{ "id": "p1", "name": "Ada", "address": { "street": "123 Main St", "city": "Leiria" } }This nested structure is representative and does not assume a specific serialization format like JSON. Each database provider may map this structure differently depending on its capabilities.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-