Skip to content

Commit 8c6393b

Browse files
committed
Update docs
1 parent 55ae75c commit 8c6393b

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/main/asciidoc/user-guide.adoc

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,11 @@ About "Multiline String Literals", please see the <<Multiline String Literals>>.
249249
====
250250

251251

252-
Also, you can specify an SQL on template file(e.g. `/NameMapper/findById.sql` on class path) as follow:
252+
Also, you can specify an SQL on template file(e.g. `NameMapper/findById.sql` on class path) as follow:
253253

254254
[source,java]
255255
----
256-
@Select("/NameMapper/findById.sql")
256+
@Select("NameMapper/findById.sql")
257257
Name findById(Integer id);
258258
----
259259

@@ -267,6 +267,12 @@ SELECT * FROM names
267267
WHERE id = /*[# mb:p="id"]*/ 1 /*[/]*/
268268
----
269269

270+
[TIP]
271+
====
272+
Since 1.0.1, we support to read a template file from under classpath automatically using the <<TemplateFilePathProvider, TemplateFilePathProvider>>.
273+
====
274+
275+
270276
==== XML driven mapper
271277

272278
If you use the XML driven mapper, you can specify an SQL on mapper XML file as follow:
@@ -298,7 +304,7 @@ Also, you can specify an SQL on template file
298304
[source,xml]
299305
----
300306
<select id="findById" resultType="com.example.Name">
301-
/NameMapper/findById.sql
307+
NameMapper/findById.sql
302308
</select>
303309
----
304310

@@ -585,11 +591,11 @@ The standard use case using this feature is paging query as follow:
585591
.Mapper interface
586592
----
587593
// Count a total record number that matches for criteria
588-
@Select("/NameMapper/countByCriteria.sql")
594+
@Select("NameMapper/countByCriteria.sql")
589595
long countByCriteria(@Param("criteria") NameCriteria criteria);
590596
591597
// Search records that matches for criteria and specified page
592-
@Select("/NameMapper/findPageByCriteria.sql")
598+
@Select("NameMapper/findPageByCriteria.sql")
593599
List<Name> findPageByCriteria(@Param("criteria") NameCriteria criteria, @Param("pageable") Pageable pageable);
594600
----
595601

@@ -655,14 +661,14 @@ You can insert a fragment SQL template file on each template as follow:
655661
[source,sql]
656662
----
657663
SELECT COUNT(*) FROM names
658-
/*[# th:insert="~{/NameMapper/whereByCriteria.sql}" /]*/ -- <1>
664+
/*[# th:insert="~{NameMapper/whereByCriteria.sql}" /]*/ -- <1>
659665
----
660666

661667
.src/main/resources/NameMapper/findPageByCriteria.sql
662668
[source,sql]
663669
----
664670
SELECT * FROM names
665-
/*[# th:insert="~{/NameMapper/whereByCriteria.sql}" /]*/ -- <1>
671+
/*[# th:insert="~{NameMapper/whereByCriteria.sql}" /]*/ -- <1>
666672
LIMIT /*[# mb:p="pageable.pageSize"]*/ 20 /*[/]*/
667673
OFFSET /*[# mb:p="pageable.offset"]*/ 0 /*[/]*/
668674
ORDER BY id
@@ -1157,7 +1163,7 @@ customizer = com.example.MyTemplateEngineCustomizer
11571163
template-file.cache-enabled = true
11581164
template-file.cache-ttl = 3600000
11591165
template-file.encoding = UTF-8
1160-
template-file.base-dir = /templates/sqls
1166+
template-file.base-dir = templates/sqls/
11611167
template-file.patterns = *sql, *.sql.template
11621168
dialect.prefix = mybatis
11631169
dialect.like-escape-char = ~
@@ -1178,7 +1184,7 @@ configuration.getLanguageRegistry().register(
11781184
c.getTemplateFile().setCacheEnabled(false);
11791185
c.getTemplateFile().setCacheTtl(3600000L);
11801186
c.getTemplateFile().setEncoding(StandardCharsets.UTF_8);
1181-
c.getTemplateFile().setBaseDir("/templates/sqls/");
1187+
c.getTemplateFile().setBaseDir("templates/sqls/");
11821188
c.getTemplateFile().setPatterns("*.sql", "*.sql.template");
11831189
c.getDialect().setPrefix("mybatis");
11841190
c.getDialect().setLikeEscapeChar('~');
@@ -1227,10 +1233,10 @@ public class Mail {
12271233
.Mapper methods
12281234
----
12291235
@Options(useGeneratedKeys = true, keyProperty = "id")
1230-
@Insert("/sqls/PersonMapper_insertByBulk.sql")
1236+
@Insert("sqls/PersonMapper_insertByBulk.sql")
12311237
void insertByBulk(List<Person> persons);
12321238
1233-
@Insert("/sqls/PersonMapper_insertMailsByBulk.sql")
1239+
@Insert("sqls/PersonMapper_insertMailsByBulk.sql")
12341240
void insertMailsByBulk(List<Person> persons);
12351241
----
12361242

0 commit comments

Comments
 (0)