Skip to content

Commit 28ffd4f

Browse files
Jason Bennettharawata
authored andcommitted
Clarify how the <cache /> tag interacts with the Java API.
1 parent f8e45df commit 28ffd4f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/site/xdoc/java-api.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
344344
<td><code>Class</code></td>
345345
<td><code>&lt;cacheRef&gt;</code></td>
346346
<td>
347-
References the cache of another namespace to use. Attributes: <code>value</code> and <code>name</code>.
347+
References the cache of another namespace to use. Note that caches declared in an XML mapper file are considered
348+
a separate namespace, even if they share the same FQCN. Attributes: <code>value</code> and <code>name</code>.
348349
If you use this annotation, you should be specified either <code>value</code> or <code>name</code> attribute.
349350
For the <code>value</code> attribute specify a java type indicating the namespace(the namespace name become a FQCN of specified java type),
350351
and for the <code>name</code> attribute(this attribute is available since 3.4.2) specify a name indicating the namespace.

src/site/xdoc/sqlmap-xml.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,7 @@ SELECT * FROM POST WHERE BLOG_ID = #{id}]]></source>
20132013
</p>
20142014

20152015
<p>
2016-
By default, just local sessión caching is enabled that is used solely to cache data for the duration of a sessión.
2016+
By default, just local session caching is enabled that is used solely to cache data for the duration of a session.
20172017
To enable a global second level of caching you simply need to add one line to your SQL Mapping file:
20182018
</p>
20192019

@@ -2037,6 +2037,13 @@ SELECT * FROM POST WHERE BLOG_ID = #{id}]]></source>
20372037
</li>
20382038
</ul>
20392039

2040+
<p>
2041+
<span class="label important">NOTE</span> The cache will only apply to statements declared in the mapping file
2042+
where the cache tag is located. If you are using the Java API in conjunction with the XML mapping files, then
2043+
statements declared in the companion interface will not be cached by default. You will need to refer to the
2044+
cache region using the @CacheNamespaceRef annotation.
2045+
</p>
2046+
20402047
<p>
20412048
All of these properties are modifiable through the attributes of the cache element. For example:
20422049
</p>

0 commit comments

Comments
 (0)