@@ -208,7 +208,7 @@ Dao インタフェースのメソッドと対応する SQL の例は次のと
208208
209209 select * from employee
210210 where
211- employee_name = /* dto.employeeName */'abc'
211+ employee_name = /* dto.employeeName */'abc'
212212 and
213213 salary = /* dto.salary */1234
214214
@@ -279,7 +279,7 @@ ifとend
279279
280280.. code-block :: sql
281281
282- select * from employee where
282+ select * from employee where
283283 /*%if employeeId != null */
284284 employee_id = /* employeeId */99
285285 /*%end*/
@@ -307,7 +307,7 @@ ifとend
307307
308308.. code-block :: sql
309309
310- select * from employee where
310+ select * from employee where
311311 /*%if employeeId != null */
312312 employee_id = /* employeeId */99
313313 /*%end*/
@@ -327,7 +327,7 @@ ifとend
327327
328328.. code-block :: sql
329329
330- select * from employee where
330+ select * from employee where
331331 /*%if employeeId != null */
332332 employee_id = /* employeeId */99
333333 /*%end*/
@@ -351,14 +351,14 @@ elseifとelse
351351
352352.. code-block :: sql
353353
354- select
355- *
354+ select
355+ *
356356 from
357- employee
358- where
357+ employee
358+ where
359359 /*%if employeeId != null */
360360 employee_id = /* employeeId */9999
361- /*%elseif department_id != null */
361+ /*%elseif department_id != null */
362362 and
363363 department_id = /* departmentId */99
364364 /*%else*/
@@ -370,35 +370,35 @@ elseifとelse
370370
371371.. code-block :: sql
372372
373- select
374- *
373+ select
374+ *
375375 from
376- employee
377- where
376+ employee
377+ where
378378 employee_id = ?
379379
380380 ``employeeId == null && department_id != null `` が成立するとき、実際は次の SQL に変換されます。
381381``department_id `` の直前の ``AND `` は自動で除去されるため出力されません。
382382
383383.. code-block :: sql
384384
385- select
386- *
385+ select
386+ *
387387 from
388- employee
389- where
388+ employee
389+ where
390390 department_id = ?
391391
392392 ``employeeId == null && department_id == null `` が成立するとき、実際は次の SQL に変換されます。
393393``department_id `` の直前の ``AND `` は自動で除去されるため出力されません。
394394
395395.. code-block :: sql
396396
397- select
398- *
397+ select
398+ *
399399 from
400- employee
401- where
400+ employee
401+ where
402402 department_id is null
403403
404404 ネストした条件コメント
@@ -408,10 +408,10 @@ elseifとelse
408408
409409.. code-block :: sql
410410
411- select * from employee where
411+ select * from employee where
412412 /*%if employeeId != null */
413413 employee_id = /* employeeId */99
414- /*%if employeeName != null */
414+ /*%if employeeName != null */
415415 and
416416 employee_name = /* employeeName */'hoge'
417417 /*%else*/
@@ -429,7 +429,7 @@ elseifとelse
429429
430430.. code-block :: sql
431431
432- select * from employee /*%if employeeId != null */
432+ select * from employee /*%if employeeId != null */
433433 where employee_id = /* employeeId */99 /*%end*/
434434
435435 また、 ``if `` と ``end `` は同じレベルの文に含まれなければいけません。
@@ -472,7 +472,7 @@ forとend
472472.. code-block :: sql
473473
474474 select * from employee where
475- employee_name like ?
475+ employee_name like ?
476476 or
477477 employee_name like ?
478478 or
@@ -502,7 +502,7 @@ item_has_nextとitem_index
502502
503503.. code-block :: sql
504504
505- select * from employee where
505+ select * from employee where
506506 /*%for name : names */
507507 employee_name like /* name */'hoge'
508508 /*%if name_has_next */
@@ -525,7 +525,7 @@ item_has_nextとitem_index
525525
526526.. code-block :: sql
527527
528- select * from employee where
528+ select * from employee where
529529 /*%for name : names */
530530 employee_name like /* name */'hoge'
531531 /*%if name_has_next */
@@ -550,14 +550,14 @@ item_has_nextとitem_index
550550また、 ``for `` と ``end `` は同じレベルの文に含まれなければいけません。
551551つまり、括弧の外で ``for `` 、括弧の内側で ``end `` という記述は認められません。
552552
553- カラムリスト展開コメント
554- ------------------------
553+ 選択カラムリスト展開コメント
554+ ----------------------------
555555
556556expand
557557~~~~~~
558558
559559SELECT節のアスタリスク ``* `` を :doc: `entity ` の定義を
560- 参照して自動でカラムのリストに展開する式をカラムリスト展開コメントと呼びます 。
560+ 参照して自動でカラムのリストに展開する式を選択カラムリスト展開コメントと呼びます 。
561561構文は次のとおりです。
562562
563563::
@@ -593,7 +593,7 @@ SELECT節のアスタリスク ``*`` を :doc:`entity` の定義を
593593 select id, name, age from employee
594594
595595 SQL 上でテーブルにエイリアスを指定する場合、
596- カラムリスト展開コメントにも同じエイリアスを指定してください 。
596+ 選択カラムリスト展開コメントにも同じエイリアスを指定してください 。
597597
598598.. code-block :: sql
599599
@@ -605,6 +605,49 @@ SQL 上でテーブルにエイリアスを指定する場合、
605605
606606 select e.id, e.name, e.age from employee e
607607
608+ .. _populate :
609+
610+ 更新カラムリスト生成コメント
611+ -----------------------------
612+
613+ populate
614+ ~~~~~~~~
615+
616+ UPDATE文のSET節 を :doc: `entity ` の定義を
617+ 参照して自動で生成する式を更新カラムリスト生成コメントと呼びます。
618+ 構文は次のとおりです。
619+
620+ ::
621+
622+ /*%populate*/
623+
624+
625+ 例を示します。
626+
627+ .. code-block :: sql
628+
629+ update employee set /*%populate*/ id = id where age < 30
630+
631+ 上記のSQL文への入力が次のような :doc: `entity ` にマッピングされているものとします。
632+
633+ .. code-block :: java
634+
635+ @Entity
636+ public class Employee {
637+ Integer id;
638+ String name;
639+ Integer age;
640+ }
641+
642+ このとき、 SQL は以下のように変換されます。
643+
644+ .. code-block :: sql
645+
646+ update employee set id = ?, name = ?, age = ? where age < 30
647+
648+ 更新カラムリスト生成コメントは、 ``/*%populate*/ `` からWHERE句までをカラムリストで置き換えます。
649+ つまり、元のSQLにあった ``id = id `` の記述は最終的なSQLからは削除されます。
650+
608651通常のブロックコメント
609652----------------------
610653
@@ -649,4 +692,3 @@ SQL 上でテーブルにエイリアスを指定する場合、
649692``-- `` は通常の行コメントだとみなされます。
650693
651694Domaでは行コメントを特別に解釈することはありません。
652-
0 commit comments