Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit e32948c

Browse files
committed
Update aggregate-strategy.rst to support BiConsumer functions
1 parent 70da60f commit e32948c

File tree

2 files changed

+40
-36
lines changed

2 files changed

+40
-36
lines changed

docs/aggregate-strategy.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,21 @@ This annotation specifies how an entity aggregate is reconstructed from a query
2929
Association linker definition
3030
===============================
3131

32-
An aggregate strategy must contain at least one field of type ``BiFunction`` annotated with ``@AssociationLinker``.
33-
This ``BiFunction`` is responsible for dynamically associating two entity instances.
32+
An aggregate strategy must contain at least one field of type ``BiConsumer`` or ``BiFunction``,
33+
annotated with ``@AssociationLinker``.
34+
These functions are responsible for dynamically associating two entity instances.
35+
Use a ``BiFunction`` when associating immutable entities.
36+
For mutable entities, you may use either a ``BiConsumer`` or a ``BiFunction``.
3437

3538
.. code-block:: java
3639
3740
@AggregateStrategy(root = Department.class, tableAlias = "d")
3841
interface DepartmentAggregateStrategy {
3942
@AssociationLinker(propertyPath = "employees", tableAlias = "e")
40-
BiFunction<Department, Employee, Department> employees =
43+
BiConsumer<Department, Employee> employees =
4144
(d, e) -> {
4245
d.getEmployees().add(e);
4346
e.setDepartment(d);
44-
return d;
4547
};
4648
4749
@AssociationLinker(propertyPath = "employees.address", tableAlias = "a")
@@ -52,11 +54,13 @@ This ``BiFunction`` is responsible for dynamically associating two entity instan
5254
};
5355
}
5456
55-
- In the ``BiFunction``, the first and third type parameters represent the class that owns the property,
56-
while the second type parameter represents the property type.
57-
- The ``propertyPath`` element specifies the target property's name as a dot-separated path from the root entity class.
57+
- The first type parameter of a ``BiConsumer`` or ``BiFunction`` represents the type of the property owner,
58+
and the second type parameter represents the type of the property.
59+
The third type parameter of a ``BiFunction`` must be the same as the first one and represents the type of
60+
the entity after the association is applied.
61+
- The ``propertyPath`` element specifies the name of the target property as a dot-separated path from the root entity class.
5862
- The ``tableAlias`` element specifies the alias for the table corresponding to the entity class used as the second
59-
type parameter of ``BiFunction``. This alias must be used in the SELECT statement.
63+
type parameter of the ``BiConsumer`` or ``BiFunction``. This alias must be used in the SELECT statement.
6064

6165
Example
6266
================

docs/locale/ja/LC_MESSAGES/aggregate-strategy.po

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ msgid ""
22
msgstr ""
33
"Project-Id-Version: doma-docs\n"
44
"Report-Msgid-Bugs-To: \n"
5-
"POT-Creation-Date: 2025-05-03 13:10+0900\n"
5+
"POT-Creation-Date: 2025-05-05 21:25+0900\n"
66
"Last-Translator: \n"
77
"Language-Team: Japanese\n"
88
"MIME-Version: 1.0\n"
@@ -48,90 +48,90 @@ msgid "Association linker definition"
4848
msgstr "関連付けリンカーの定義"
4949

5050
#: ../../aggregate-strategy.rst:32
51-
msgid "An aggregate strategy must contain at least one field of type ``BiFunction`` annotated with ``@AssociationLinker``. This ``BiFunction`` is responsible for dynamically associating two entity instances."
52-
msgstr "アグリゲート戦略には、``@AssociationLinker`` で注釈された ``BiFunction`` 型のフィールドが少なくとも1つ含まれている必要があります。``BiFunction`` は、2つのエンティティインスタンスを動的に関連付ける責任があります。"
53-
54-
#: ../../aggregate-strategy.rst:55
55-
msgid "In the ``BiFunction``, the first and third type parameters represent the class that owns the property, while the second type parameter represents the property type."
56-
msgstr "``BiFunction`` の最初と 3 番目の型パラメータはプロパティを所有するクラスを表し、2 番目の型パラメータはプロパティの型を表します。"
51+
msgid "An aggregate strategy must contain at least one field of type ``BiConsumer`` or ``BiFunction``, annotated with ``@AssociationLinker``. These functions are responsible for dynamically associating two entity instances. Use a ``BiFunction`` when associating immutable entities. For mutable entities, you may use either a ``BiConsumer`` or a ``BiFunction``."
52+
msgstr "アグリゲート戦略には、 ``@AssociationLinker`` で注釈された ``BiConsumer`` または ``BiFunction`` 型のフィールドが少なくとも1つ含まれている必要があります。これらの関数は、2つのエンティティインスタンスを動的に関連付ける責任があります。不変エンティティを関連付ける場合は、``BiFunction`` を使用します。変更可能なエンティティの場合は、``BiConsumer`` または ``BiFunction`` のいずれかを使用できます。"
5753

5854
#: ../../aggregate-strategy.rst:57
59-
msgid "The ``propertyPath`` element specifies the target property's name as a dot-separated path from the root entity class."
55+
msgid "The first type parameter of a ``BiConsumer`` or ``BiFunction`` represents the type of the property owner, and the second type parameter represents the type of the property. The third type parameter of a ``BiFunction`` must be the same as the first one and represents the type of the entity after the association is applied."
56+
msgstr "``BiConsumer`` と ``BiFunction`` の1番目の型パラメータはプロパティオーナーの型を表し、2番目の型パラメータはプロパティの型を表します。 ``BiFunction`` の3番目の型パラメータは1番目のものと同じでなければならず、関連付けが適用された後のエンティティの型を表します。"
57+
58+
#: ../../aggregate-strategy.rst:61
59+
msgid "The ``propertyPath`` element specifies the name of the target property as a dot-separated path from the root entity class."
6060
msgstr "``propertyPath`` 要素は、ルートエンティティクラスからドットで区切られたパスとしてターゲットプロパティの名前を指定します。"
6161

62-
#: ../../aggregate-strategy.rst:58
63-
msgid "The ``tableAlias`` element specifies the alias for the table corresponding to the entity class used as the second type parameter of ``BiFunction``. This alias must be used in the SELECT statement."
62+
#: ../../aggregate-strategy.rst:62
63+
msgid "The ``tableAlias`` element specifies the alias for the table corresponding to the entity class used as the second type parameter of the ``BiConsumer`` or ``BiFunction``. This alias must be used in the SELECT statement."
6464
msgstr "``tableAlias`` 要素は、``BiFunction`` の 2 番目の型パラメータとして使用されるエンティティクラスに対応するテーブルのエイリアスを指定します。 このエイリアスはSELECT文で使用する必要があります。"
6565

66-
#: ../../aggregate-strategy.rst:62
66+
#: ../../aggregate-strategy.rst:66
6767
msgid "Example"
6868
msgstr "例"
6969

70-
#: ../../aggregate-strategy.rst:64
70+
#: ../../aggregate-strategy.rst:68
7171
msgid "The ``DepartmentAggregateStrategy`` described above is based on the following entity definitions:"
7272
msgstr "上記の ``DepartmentAggregateStrategy`` は以下のエンティティ定義に基づいています。"
7373

74-
#: ../../aggregate-strategy.rst:97
74+
#: ../../aggregate-strategy.rst:101
7575
msgid "In entity classes, association properties must be annotated with ``@Association``. These properties can be linked using ``@AssociationLinker``."
7676
msgstr "エンティティクラスでは、関連プロパティに ``@Association`` を付与する必要があります。これらのプロパティは ``@AssociationLinker`` を使用してリンクできます。"
7777

78-
#: ../../aggregate-strategy.rst:101
78+
#: ../../aggregate-strategy.rst:105
7979
msgid "Using an aggregate strategy"
8080
msgstr "アグリゲート戦略の使用"
8181

82-
#: ../../aggregate-strategy.rst:103
82+
#: ../../aggregate-strategy.rst:107
8383
msgid "``DepartmentAggregateStrategy`` is used by specifying it in the ``aggregateStrategy`` element of ``@Select``:"
8484
msgstr "``DepartmentAggregateStrategy`` は ``@Select`` の ``aggregateStrategy`` 要素に指定することで使用されます。"
8585

86-
#: ../../aggregate-strategy.rst:113
86+
#: ../../aggregate-strategy.rst:117
8787
msgid "The ``selectById`` method requires a SELECT statement like the following:"
8888
msgstr "``selectById`` メソッドは、次のような SELECT ステートメントを必要とします:"
8989

90-
#: ../../aggregate-strategy.rst:137
90+
#: ../../aggregate-strategy.rst:141
9191
msgid "The SELECT list must include the IDs of all entities that form the aggregate."
9292
msgstr "SELECTリストにはアグリゲートを形成するすべてのエンティティのIDを含める必要があります。"
9393

94-
#: ../../aggregate-strategy.rst:140
94+
#: ../../aggregate-strategy.rst:144
9595
msgid "Column aliasing rules"
9696
msgstr "カラムエイリアスのルール"
9797

98-
#: ../../aggregate-strategy.rst:142
98+
#: ../../aggregate-strategy.rst:146
9999
msgid "Table aliases must match those defined in ``DepartmentAggregateStrategy``."
100100
msgstr "テーブルエイリアスは ``DepartmentAggregateStrategy`` で定義されているものと一致する必要があります。"
101101

102-
#: ../../aggregate-strategy.rst:143
102+
#: ../../aggregate-strategy.rst:147
103103
msgid "Column aliases must begin with the table alias followed by an underscore (``_``). For example, ``d.id`` should be aliased as ``d_id`` and ``e.id`` as ``e_id``."
104104
msgstr "カラムのエイリアスは、テーブルのエイリアスにアンダースコア(``_``)を付けた形式で指定する必要があります。例えば、``d.id`` は ``d_id``、``e.id`` は ``e_id`` としてエイリアスされます。"
105105

106-
#: ../../aggregate-strategy.rst:147
106+
#: ../../aggregate-strategy.rst:151
107107
msgid "Using the expansion directive"
108108
msgstr "選択カラムリスト展開ディレクティブの使用"
109109

110-
#: ../../aggregate-strategy.rst:149
110+
#: ../../aggregate-strategy.rst:153
111111
msgid "By using the :ref:`expansion directive <expand>`, the above SELECT statement can be written more concisely:"
112112
msgstr ":ref:`選択カラムリスト展開ディレクティブ <expand>` を使用することで、上記のSELECT文をより簡潔に記述することができます。"
113113

114-
#: ../../aggregate-strategy.rst:166
114+
#: ../../aggregate-strategy.rst:170
115115
msgid "How expansion works"
116116
msgstr "カラムリスト展開の仕組み"
117117

118-
#: ../../aggregate-strategy.rst:168
118+
#: ../../aggregate-strategy.rst:172
119119
msgid "The ``/*%expand*/*`` directive automatically expands into a column list following predefined aliasing rules."
120120
msgstr "``/*%expand */*`` ディレクティブは、あらかじめ定義されたエイリアスルールを使用して列リストに自動的に展開します。"
121121

122-
#: ../../aggregate-strategy.rst:169
122+
#: ../../aggregate-strategy.rst:173
123123
msgid "By default, all columns from all tables are included in the result set."
124124
msgstr "デフォルトでは、すべてのテーブルのすべての列が結果セットに含まれます。"
125125

126-
#: ../../aggregate-strategy.rst:171
126+
#: ../../aggregate-strategy.rst:175
127127
msgid "To selectively expand only specific tables, pass a comma-separated list of table aliases:"
128128
msgstr "特定のテーブルのみを選択的に展開するには、テーブルエイリアスのカンマ区切りリストを渡します。"
129129

130-
#: ../../aggregate-strategy.rst:188
130+
#: ../../aggregate-strategy.rst:192
131131
msgid "Here, only columns from tables ``e`` (``employee``) and ``d`` (``department``) are expanded."
132132
msgstr "ここでは、テーブルの ``e`` (``employee``) と ``d`` (``department``) のカラムのみが展開されます。"
133133

134-
#: ../../aggregate-strategy.rst:189
134+
#: ../../aggregate-strategy.rst:193
135135
msgid "The columns from table ``a`` (``address``) are explicitly specified."
136136
msgstr "テーブル ``a`` (``address``) の列は明示的に指定されています。"
137137

0 commit comments

Comments
 (0)