Skip to content

Commit

Permalink
docs: include array support
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <[email protected]>
  • Loading branch information
otaviojava committed Aug 10, 2024
1 parent 0065c0e commit ac563fa
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions spec/src/main/asciidoc/chapters/api/entity.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,55 @@ However, every Jakarta NoSQL provider is strongly encouraged to support embeddab
Some databases might require the use of the `udt` attribute in the `@Column` annotation for embedded fields.
====


==== Array Support

Jakarta NoSQL implementations MUST support binding Java arrays of the basic types, as referenced in <<basic_types>>, and arrays of entities and embedded classes.

Arrays of entities and embedded classes are supported and will function as embedded classes with *grouping*.

Consider an entity class `Library` with an array of `Book` entities and an array of `String` tags.

[source,java]
----
@Entity
public class Library {
@Id
private Long id;
@Column
private Book[] books;
@Column
private String[] tags;
}
@Entity
public class Book {
@Id
private Long id;
@Column
private String title;
}
----

In this example, the array of `Book` entities will be treated as an embedded collection within the `Library` entity, using *grouping* to represent the structure.

The JSON representation of an instance of the `Library` entity might be:

[source,json]
----
{
"id": 1,
"books": [
{"id": 101, "title": "Java Programming"},
{"id": 102, "title": "Introduction to NoSQL"}
],
"tags": ["Programming", "NoSQL", "Java"]
}
----

==== Entity Associations

An association field is a field of an entity class whose declared type is also an entity class.
Expand Down

0 comments on commit ac563fa

Please sign in to comment.