You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -42,15 +44,15 @@ If you are not familiar with MyBatis and Thymeleaf, you can see following offici
42
44
The 2-way SQL can be used by following *two way*.
43
45
44
46
* It can be executed as-is in SQL execution tool (such as psql, mysql, sqlplus, plugins for IDE, etc...)
45
-
* It can be used as a SQL template for creating a bindable and dynamically SQL on your application
47
+
* It can be used as a SQL template for creating a bindable and dynamically SQL that can be parsed by MyBatis core module
46
48
47
49
==== Simple bindable 2-way SQL
48
50
49
-
The mybatis-thymeleaf translate a simple bindable 2-way SQL that specified by natural template to as follow:
51
+
The mybatis-thymeleaf support a simple bindable 2-way SQL as follow:
50
52
51
53
52
54
[source,sql]
53
-
.SQL Template using custom attribute tag provided by mybatis-thymeleaf
55
+
.SQL Template
54
56
----
55
57
SELECT * FROM names
56
58
WHERE id = /*[# mb:p="id"]*/ 1 /*[/]*/
@@ -59,10 +61,10 @@ SELECT * FROM names
59
61
60
62
==== Dynamically bindable 2-way SQL
61
63
62
-
The mybatis-thymeleaf translate a dynamically bindable 2-way SQL that specified by natural template to as follow:
64
+
The mybatis-thymeleaf support a dynamically bindable 2-way SQL as follow:
63
65
64
66
[source,sql]
65
-
.SQL Template using custom attribute tag provided by mybatis-thymeleaf
67
+
.SQL Template
66
68
----
67
69
SELECT * FROM names
68
70
WHERE 1 = 1
@@ -74,10 +76,10 @@ SELECT * FROM names
74
76
75
77
==== Dynamically bindable SQL
76
78
77
-
The mybatis-thymeleaf translate a dynamically bindable SQL(non 2-way SQL) that specified by template to as follow:
79
+
The mybatis-thymeleaf support a dynamically bindable SQL(non 2-way SQL) as follow:
78
80
79
81
[source,sql]
80
-
.SQL Template using custom attribute tag provided by mybatis-thymeleaf
82
+
.SQL Template
81
83
----
82
84
SELECT * FROM names
83
85
WHERE 1 = 1
@@ -96,8 +98,8 @@ for integrating with template engine provide by Thymeleaf.
96
98
97
99
* Can write 2-way SQL/dynamic SQL
98
100
* Can use a 2-way SQL/dynamic SQL via an annotation and mapper xml
99
-
* Can read an SQL template from a template file on classpath
100
-
* Can use a custom dialect(attribute tag and expression utility method) at a template
101
+
* Can read an SQL template from a Thymeleaf template file on classpath
102
+
* Can use a custom dialect(attribute tag and expression utility method) on your SQL template
101
103
* Can fully customize a template engine configuration
102
104
103
105
@@ -456,7 +458,7 @@ SELECT * FROM names
456
458
----
457
459
458
460
[source,sql]
459
-
.2-way SQL template for generating string that can be parsed by MyBatis core module
461
+
.SQL template for generating string that can be parsed by MyBatis core module
460
462
----
461
463
SELECT * FROM names
462
464
WHERE id = /*[# mb:p="id"]*/ 1 /*[/]*/ -- <2>
@@ -477,7 +479,7 @@ About usage of `mb:bind`, please see <<Attribute tag>>.
477
479
=== Dynamic SQL
478
480
479
481
The Thymeleaf supports to create an any string dynamically using conditional evaluation
480
-
and iterating evaluation feature. By using this feature, you can write a dynamic 2-way SQL.
482
+
and iterating evaluation feature. By using this feature, you can write a dynamic SQL.
481
483
482
484
* <<Using tag for specifying condition>>
483
485
* <<Using tag for iteration>>
@@ -545,21 +547,21 @@ SELECT * FROM names
545
547
546
548
<1> Specify an iterable object on `th:each`
547
549
548
-
<2> Specify a 2-way SQL of binding value per iterable element.
549
-
A bind value specify by `mb:p="{variable name of iterable element}"` format.
550
+
<2> Specify a SQL template of binding value per iterable element.
551
+
A bind value specify by `mb:p="{variable name of iterable element}"` format (e.g. `id`).
550
552
551
553
<3> Append comma character when element position is not last.
552
-
You can access an iteration status object (`IterationStatusVar`) that named by `"{variable name of iterable element}Stat"` format.
554
+
You can access an iteration status object (`IterationStatusVar`) that named by `"{variable name of iterable element}Stat"` format (e.g. `idStat`).
553
555
554
556
<4> Specify an end tag of iteration
555
557
556
558
[TIP]
557
559
====
558
-
Also, an above SQL template can be replaced using `mb:p` attribute tag with following SQL template.
560
+
An above SQL template can be replaced using `mb:p` attribute tag with following SQL template.
559
561
560
562
561
563
[source,sql]
562
-
.Use `mb:p` for creating bind variables string of IN clause
564
+
.Use mb:p for creating bind variables string of IN clause
563
565
----
564
566
SELECT * FROM names
565
567
WHERE 1 = 1
@@ -570,17 +572,17 @@ SELECT * FROM names
570
572
----
571
573
====
572
574
573
-
About more advanced usage, please see <<Bulk insert>>.
575
+
About more advanced usage of `th:each` , please see <<Bulk insert>>.
574
576
575
577
=== Fragment
576
578
577
579
The Thymeleaf supports to insert template string from an another template file.
578
-
By using this feature, you can share a 2-way SQL on multiple SQL template.
580
+
By using this feature, you can share an SQL on multiple SQL template.
579
581
580
582
The standard use case using this feature is paging query as follow:
581
583
582
584
[source,java]
583
-
.Mapper
585
+
.Mapper interface
584
586
----
585
587
// Count a total record number that matches for criteria
586
588
@Select("/NameMapper/countByCriteria.sql")
@@ -670,7 +672,7 @@ SELECT * FROM names
670
672
671
673
=== Special variables
672
674
673
-
The mybatis and mybatis-thymeleaf provides special variables that prefixed with `_` as follows:
675
+
The MyBatis core module provides special variables that prefixed with `_` as follows:
674
676
675
677
[cols="2,7,1",options="header"]
676
678
.Special variables
@@ -684,7 +686,7 @@ The mybatis and mybatis-thymeleaf provides special variables that prefixed with
684
686
|Any type
685
687
686
688
|`_databaseId`
687
-
|The id for identifying the database
689
+
|The id for identifying the database on current session
688
690
(If you want to this variable, you should be enabled the link:{mybatis-doc-url}/configuration.html#databaseIdProvider[`DatabaseIdProvider` feature^] on MyBatis)
689
691
|`String`
690
692
|===
@@ -695,7 +697,7 @@ You can access the configuration properties of MyBatis from your SQL template.
695
697
About configuration properties, please see the link:{mybatis-doc-url}/configuration.html#properties[MyBatis reference documentation^].
696
698
697
699
[source,java]
698
-
.Java based configuration
700
+
.How to set configuration properties using Java based configuration
699
701
----
700
702
Configuration configuration = new Configuration();
Valid format is same with link:{mybatis-doc-url}/sqlmap-xml.html#Parameters[MyBatis's inline parameter format^].
@@ -838,9 +841,9 @@ SELECT * FROM names
838
841
WHERE id IN (/*[# mb:p="ids"]*/ 1 /*[/]*/) -- <3>
839
842
----
840
843
841
-
<1> Render single bind variable(e.g. `#{id}`) that can parsed MyBatis when specify a simple value object
844
+
<1> Render single bind variable(e.g. `#{id}`) that can be parsed by MyBatis core module when specify a simple value object
842
845
<2> Can specify parameter options(`key=value` format) separate with comma
843
-
<3> Render multiple bind variables(e.g. `#{ids[0]}, #{ids[1]}, ...`) that can parsed MyBatis when specify a collection or array object
846
+
<3> Render multiple bind variables(e.g. `#{ids[0]}, #{ids[1]}, ...`) that can be parsed by MyBatis core module when specify a collection or array object
844
847
845
848
846
849
[[mybatis-bind]]
@@ -902,13 +905,13 @@ The `#likes` expression provide utility methods for LIKE clause.
902
905
!A target value
903
906
!===
904
907
905
-
|Return a value that escaped a wildcard character of LIKE condition
906
-
(By default behavior, this method escape the `"%"`, `"_"` and `"\"`(escape character itself) using `"\"`)
908
+
|Return a value that escaped a wildcard character of LIKE condition.
909
+
By default behavior, this method escape the `"%"`, `"_"` and `"\"`(escape character itself) using `"\"`.
907
910
908
911
|<<mybatis-likeEscapeClause,escapeClause>>
909
-
| N/A
910
-
|Return a escape clause string of LIKE condition
911
-
( By default behavior, this method return `"ESCAPE '\'"`)
912
+
| None
913
+
|Return a escape clause string of LIKE condition.
914
+
By default behavior, this method return `"ESCAPE '\'"`.
912
915
|===
913
916
914
917
@@ -1247,3 +1250,25 @@ fun findById(id: Int): Name
1247
1250
Todo findById(int id);
1248
1251
----
1249
1252
1253
+
=== Related resources
1254
+
1255
+
1256
+
[cols="2,8",options="header"]
1257
+
.Related resource list
1258
+
|===
1259
+
^|Resource name
1260
+
^|Description
1261
+
1262
+
|link:{github-url}[GiHub Page^]
1263
+
|The mybatis-thymeleaf GiHub top page
1264
+
1265
+
|link:{github-wiki-url}/Usage-on-framework[Usage on framework^]
1266
+
|Explain how to integrate with an application framework
0 commit comments