Skip to content

Commit c781315

Browse files
committed
Add documents
1 parent 26f8fbe commit c781315

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

docs/domain.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ The value ``new`` means that the object of annotated class is created with a con
4545
}
4646
}
4747
48+
.. note::
49+
In Java 14 and later version, you can annotate `records`_ with ``@Domain``:
50+
51+
.. code-block:: java
52+
53+
@Domain(valueType = String.class, accessorMethod = "value")
54+
public record PhoneNumber(String value) {
55+
public String getAreaCode() {
56+
...
57+
}
58+
}
59+
60+
.. _records: https://openjdk.java.net/jeps/359
61+
62+
4863
Instantiation with a static factory method
4964
------------------------------------------
5065

docs/embeddable.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ The above entity definition is equivalent to following one:
6060
String zip;
6161
}
6262
63+
.. note::
64+
In Java 14 and later version, you can annotate `records`_ with ``@Embeddable``:
65+
66+
.. code-block:: java
67+
68+
@Embeddable
69+
public record Address(
70+
String city,
71+
String street,
72+
@Column(name = "ZIP_CODE")String zip) {
73+
}
74+
75+
.. _records: https://openjdk.java.net/jeps/359
6376

6477
Naming convention
6578
-----------------

docs/entity.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ The following code snippet shows how to inherit other entity class:
3030
...
3131
}
3232
33+
.. note::
34+
In Java 14 and later version, you can annotate `records`_ with ``@Entity``:
35+
36+
.. code-block:: java
37+
38+
@Entity
39+
public record Employee(...) {
40+
}
41+
42+
In the case, the entity is recognize as :ref:`immutable`
43+
even though the immutable property of ``@Entity`` is ``false``.
44+
45+
.. _records: https://openjdk.java.net/jeps/359
3346

3447
Entity listeners
3548
---------------------------
@@ -77,6 +90,8 @@ the naming convention is ignored.
7790

7891
An entity subclass inherits parent's naming convention.
7992

93+
.. _immutable:
94+
8095
Immutable
8196
----------------------------
8297

src/main/java/org/seasar/doma/Entity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@
105105
* <p>If not specified and the entity class inherits another entity class, this value is inherited
106106
* from the parent entity class. The values must be consistent in the hierarchy.
107107
*
108+
* <p>If not specified and the entity class is a record, the class is recognized as immutable even
109+
* though this value is {@code false}.
110+
*
108111
* @return whether the entity class is immutable
109112
*/
110113
boolean immutable() default false;

0 commit comments

Comments
 (0)