Skip to content

Commit c065fd6

Browse files
c19354837harawata
authored andcommitted
Complete translation of configuration and sqlmap-xml (#780)
Complete translation of configuration and sqlmap-xml
1 parent 3ad1988 commit c065fd6

File tree

2 files changed

+41
-51
lines changed

2 files changed

+41
-51
lines changed

src/site/zh/xdoc/configuration.xml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader, environment,
250250
设置超时时间,它决定驱动等待数据库响应的秒数。
251251
</td>
252252
<td>
253-
Any positive integer
253+
任意正整数
254254
</td>
255255
<td>
256256
Not Set (null)
@@ -261,11 +261,10 @@ SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader, environment,
261261
defaultFetchSize
262262
</td>
263263
<td>
264-
Sets the driver a hint as to control fetching size for return results.
265-
This parameter value can be override by a query setting.
264+
为驱动的结果集获取数量(fetchSize)设置一个提示值。此参数只可以在查询设置中被覆盖。
266265
</td>
267266
<td>
268-
Any positive integer
267+
任意正整数
269268
</td>
270269
<td>
271270
Not Set (null)
@@ -435,10 +434,10 @@ SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader, environment,
435434
vfsImpl
436435
</td>
437436
<td>
438-
Specifies VFS implementations
437+
指定VFS的实现
439438
</td>
440439
<td>
441-
Fully qualified class names of custom VFS implementation separated by commas.
440+
自定义VFS的实现的类全限定名,以逗号分隔。
442441
</td>
443442
<td>
444443
Not set
@@ -449,8 +448,8 @@ SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader, environment,
449448
useActualParamName
450449
</td>
451450
<td>
452-
Allow referencing statement parameters by their actual names declared in the method signature.
453-
To use this feature, your project must be compiled in Java 8 with <code>-parameters</code> option. (Since: 3.4.1)
451+
允许使用方法签名中的名称作为语句参数名称。
452+
为了使用该特性,你的工程必须采用Java 8编译,并且加上<code>-parameters</code>选项。(从3.4.1开始)
454453
</td>
455454
<td>
456455
true | false
@@ -745,8 +744,7 @@ public class Author {
745744
都会用类型处理器将获取的值以合适的方式转换成 Java 类型。下表描述了一些默认的类型处理器。</p>
746745
<p>
747746
<span class="label important">NOTE</span>
748-
If you use classes provided by JSR-310(Date and Time API),
749-
you can use the <a href="https://github.com/mybatis/typehandlers-jsr310">mybatis-typehandlers-jsr310</a>.
747+
如果你使用JSR-310(Date和Time API),你可以使用<a href="https://github.com/mybatis/typehandlers-jsr310">mybatis-typehandlers-jsr310</a>。
750748
</p>
751749
<table>
752750
<thead>
@@ -1106,15 +1104,11 @@ public class ExampleTypeHandler extends BaseTypeHandler<String> {
11061104
</ul>
11071105

11081106
<p>
1109-
When deciding which TypeHandler to use in a <code>ResultMap</code>, the Java type is known
1110-
(from the result type), but the JDBC type is unknown. MyBatis therefore uses the combination
1111-
<code>javaType=[TheJavaType], jdbcType=null</code> to choose a TypeHandler. This means that
1112-
using a <code>@MappedJdbcTypes</code> annotation <i>restricts</i> the scope of a TypeHandler
1113-
and makes it unavailable for use in <code>ResultMap</code>s unless explicity set. To make a
1114-
TypeHandler available for use in a <code>ResultMap</code>, set <code>includeNullJdbcType=true</code>
1115-
on the <code>@MappedJdbcTypes</code> annotation. Since Mybatis 3.4.0 however, if a <b>single</b>
1116-
TypeHandler is registered to handle a Java type, it will be used by default in <code>ResultMap</code>s
1117-
using this Java type (i.e. even without <code>includeNullJdbcType=true</code>).
1107+
当决定在<code>ResultMap</code>中使用某一TypeHandler时,此时java类型是已知的(从结果类型中获得),但是JDBC类型是未知的。
1108+
因此Mybatis使用<code>javaType=[TheJavaType], jdbcType=null</code>的组合来选择一个TypeHandler。
1109+
这意味着使用<code>@MappedJdbcTypes</code>注解可以<i>限制</i>TypeHandler的范围,同时除非显示的设置,否则TypeHandler在<code>ResultMap</code>中将是无效的。
1110+
如果希望在<code>ResultMap</code>中使用TypeHandler,那么设置<code>@MappedJdbcTypes</code>注解的<code>includeNullJdbcType=true</code>即可。
1111+
然而从Mybatis 3.4.0开始,如果<b>只有一个</b>注册的TypeHandler来处理Java类型,那么它将是<code>ResultMap</code>使用Java类型时的默认值(即使没有<code>includeNullJdbcType=true</code>)。
11181112
</p>
11191113

11201114
<p>最后,可以让 MyBatis 为你查找类型处理器:</p>

src/site/zh/xdoc/sqlmap-xml.xml

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -788,11 +788,11 @@ resultMap 元素有很多子元素和一个值得讨论的结构。
788788
</ul>
789789

790790
<table>
791-
<caption>ResultMap Attributes</caption>
791+
<caption>ResultMap属性</caption>
792792
<thead>
793793
<tr>
794-
<th>Attribute</th>
795-
<th>Description</th>
794+
<th>属性</th>
795+
<th>描述</th>
796796
</tr>
797797
</thead>
798798
<tbody>
@@ -1185,8 +1185,8 @@ prop1 和 prop2 以参数对象形式来设置给目标嵌套查询语句。
11851185
<tr>
11861186
<td><code>fetchType</code></td>
11871187
<td>
1188-
Optional. Valid values are <code>lazy</code> and <code>eager</code>. If present, it supersedes
1189-
the global configuration parameter <code>lazyLoadingEnabled</code> for this mapping.
1188+
可选的。有效值为 <code>lazy</code><code>eager</code>
1189+
如果使用了,它将取代全局配置参数<code>lazyLoadingEnabled</code>
11901190
</td>
11911191
</tr>
11921192
</tbody>
@@ -1269,25 +1269,25 @@ resultMap
12691269
<tr>
12701270
<td><code>columnPrefix</code></td>
12711271
<td>
1272-
When joining multiple tables, you would have to use column alias to avoid duplicated
1273-
column names in the ResultSet. Specifying columnPrefix allows you to map such columns
1274-
to an external resultMap. Please see the example explained later in this section.
1272+
当连接多表时,你将不得不使用列别名来避免ResultSet中的重复列名。指定columnPrefix允许你映射列名到一个外部的结果集中。
1273+
请看后面的例子。
12751274
</td>
12761275
</tr>
12771276
<tr>
12781277
<td><code>notNullColumn</code></td>
12791278
<td>
1280-
By default a child object is created only if at least one of the columns mapped to the child's properties
1281-
is non null. With this attribute you can change this behaviour by specifiying which columns must have a value
1282-
so MyBatis will create a child object only if any of those columns is not null. Multiple column names can be
1283-
specified using a comma as a separator. Default value: unset.
1279+
默认情况下,子对象仅在至少一个列映射到其属性非空时才创建。
1280+
通过对这个属性指定非空的列将改变默认行为,这样做之后Mybatis将仅在这些列非空时才创建一个子对象。
1281+
可以指定多个列名,使用逗号分隔。默认值:未设置(unset)。
12841282
</td>
12851283
</tr>
12861284
<tr>
12871285
<td><code>autoMapping</code></td>
1288-
<td>If present, MyBatis will enable or disable auto-mapping when mapping the result to this property.
1289-
This attribute overrides the global autoMappingBehavior.
1290-
Note that it has no effect on an external resultMap, so it is pointless to use it with <code>select</code> or <code>resultMap</code> attribute. Default value: unset.
1286+
<td>
1287+
如果使用了,当映射结果到当前属性时,Mybatis将启用或者禁用自动映射。
1288+
该属性覆盖全局的自动映射行为。
1289+
注意它对外部结果集无影响,所以在<code>select</code> or <code>resultMap</code>属性中这个是毫无意义的。
1290+
默认值:未设置(unset)。
12911291
</td>
12921292
</tr>
12931293
</tbody>
@@ -1363,8 +1363,8 @@ resultMap
13631363
</resultMap>]]></source>
13641364

13651365
<p>
1366-
What if the blog has a co-author?
1367-
The select statement would look like:
1366+
如果blog有一个co-author怎么办?
1367+
select语句将看起来这个样子:
13681368
</p>
13691369

13701370
<source><![CDATA[<select id="selectBlog" resultMap="blogResult">
@@ -1388,7 +1388,7 @@ resultMap
13881388
</select>]]></source>
13891389

13901390
<p>
1391-
Recall that the resultMap for Author is defined as follows.
1391+
再次调用Author的resultMap将定义如下:
13921392
</p>
13931393

13941394
<source><![CDATA[<resultMap id="authorResult" type="Author">
@@ -1400,8 +1400,8 @@ resultMap
14001400
</resultMap>]]></source>
14011401

14021402
<p>
1403-
Because the column names in the results differ from the columns defined in the resultMap,
1404-
you need to specify <code>columnPrefix</code> to reuse the resultMap for mapping co-author results.
1403+
因为结果中的列名与resultMap中的列名不同。
1404+
你需要指定<code>columnPrefix</code>去重用映射co-author结果的resultMap。
14051405
</p>
14061406

14071407
<source><![CDATA[<resultMap id="blogResult" type="Blog">
@@ -1700,25 +1700,23 @@ MyBatis 会从结果集中得到每条记录,
17001700
</resultMap>]]></source>
17011701

17021702
<p>
1703-
There are three auto-mapping levels:
1703+
有三种自动映射等级:
17041704
</p>
17051705

17061706
<ul>
17071707
<li>
1708-
<code>NONE</code> - disables auto-mapping. Only manually mapped properties will be set.
1708+
<code>NONE</code> - 禁用自动映射。仅设置手动映射属性。
17091709
</li>
17101710
<li>
1711-
<code>PARTIAL</code> - will auto-map results except those that have nested result mappings defined inside (joins).
1711+
<code>PARTIAL</code> - 将自动映射结果除了那些有内部定义内嵌结果映射的(joins).
17121712
</li>
17131713
<li>
1714-
<code>FULL</code> - auto-maps everything.
1714+
<code>FULL</code> - 自动映射所有。
17151715
</li>
17161716
</ul>
17171717

17181718
<p>
1719-
The default value is <code>PARTIAL</code>, and it is so for a reason. When <code>FULL</code> is used auto-mapping will
1720-
be performed when processing join results and joins retrieve data of several different entities in the same row
1721-
hence this may result in undesired mappings. To understand the risk have a look at the following sample:
1719+
默认值是<code>PARTIAL</code>,这是有原因的。当使用<code>FULL</code>时,自动映射会在处理join结果时执行,并且join取得若干相同行的不同实体数据,因此这可能导致非预期的映射。下面的例子将展示这种风险:
17221720
</p>
17231721

17241722
<source><![CDATA[<select id="selectBlog" resultMap="blogResult">
@@ -1739,14 +1737,12 @@ MyBatis 会从结果集中得到每条记录,
17391737
</resultMap>]]></source>
17401738

17411739
<p>
1742-
With this result map both <i>Blog</i> and <i>Author</i> will be auto-mapped. But note that <i>Author</i> has an <i>id</i>
1743-
property and there is a column named <i>id</i> in the ResultSet so Author's id will be filled with Blog's id, and that is not
1744-
what you were expecting. So use the <code>FULL</code> option with caution.
1740+
在结果中<i>Blog</i>和<i>Author</i>均将自动映射。但是注意<i>Author</i>有一个<i>id</i>属性,在ResultSet中有一个列名为<i>id</i>,
1741+
所以Author的id将被填充为Blog的id,这不是你所期待的。所以需要谨慎使用<code>FULL</code>。
17451742
</p>
17461743

17471744
<p>
1748-
Regardless of the auto-mapping level configured you can enable or disable the automapping for an specific ResultMap
1749-
by adding the attribute <code>autoMapping</code> to it:
1745+
通过添加<code>autoMapping</code>属性可以忽略自动映射等级配置,你可以启用或者禁用自动映射指定的ResultMap。
17501746
</p>
17511747

17521748
<source><![CDATA[<resultMap id="userResultMap" type="User" autoMapping="false">

0 commit comments

Comments
 (0)