Skip to content

Commit 2215189

Browse files
translate the datavaseId intro
1 parent 233f113 commit 2215189

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/site/zh/xdoc/java-api.xml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,9 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
414414
<td><code>方法</code></td>
415415
<td>映射语句的属性</td>
416416
       <td>该注解允许你指定大部分开关和配置选项,它们通常在映射语句上作为属性出现。与在注解上提供大量的属性相比,<code>Options</code> 注解提供了一致、清晰的方式来指定选项。属性:<code>useCache=true</code>、<code>flushCache=FlushCachePolicy.DEFAULT</code>、<code>resultSetType=DEFAULT</code>、<code>statementType=PREPARED</code>、<code>fetchSize=-1</code>、<code>timeout=-1</code>、<code>useGeneratedKeys=false</code>、<code>keyProperty=""</code>、<code>keyColumn=""</code>、<code>resultSets=""</code>, <code>databaseId=""</code>。注意,Java 注解无法指定 <code>null</code> 值。因此,一旦你使用了 <code>Options</code> 注解,你的语句就会被上述属性的默认值所影响。要注意避免默认值带来的非预期行为。
417-
The <code>databaseId</code>(Available since 3.5.5), in case there is a configured <code>DatabaseIdProvider</code>,
418-
the MyBatis use the <code>Options</code> with no <code>databaseId</code> attribute or with a <code>databaseId</code>
419-
that matches the current one. If found with and without the <code>databaseId</code> the latter will be discarded.<br/><br/>
420-
417+
<code>databaseId</code>(3.5.5以上可用), 如果有一个配置好的 <code>DatabaseIdProvider</code>,
418+
MyBatis 会加载不带 <code>databaseId</code> 属性和带有匹配当前数据库 <code>databaseId</code> 属性的所有语句。如果同时存在带 <code>databaseId</code> 和不带 <code>databaseId</code> 属性的相同语句,则后者会被舍弃。<br/><br/>
419+
421420
       注意:<code>keyColumn</code> 属性只在某些数据库中有效(如 Oracle、PostgreSQL 等)。要了解更多关于 <code>keyColumn</code> 和 <code>keyProperty</code> 可选值信息,请查看“insert, update 和 delete”一节。</td>
422421
</tr>
423422
<tr>
@@ -440,9 +439,8 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
440439
</td>
441440
       <td>
442441
每个注解分别代表将会被执行的 SQL 语句。它们用字符串数组(或单个字符串)作为参数。如果传递的是字符串数组,字符串数组会被连接成单个完整的字符串,每个字符串之间加入一个空格。这有效地避免了用 Java 代码构建 SQL 语句时产生的“丢失空格”问题。当然,你也可以提前手动连接好字符串。属性:<code>value</code>,指定用来组成单个 SQL 语句的字符串数组。
443-
The <code>databaseId</code>(Available since 3.5.5), in case there is a configured <code>DatabaseIdProvider</code>,
444-
the MyBatis use a statement with no <code>databaseId</code> attribute or with a <code>databaseId</code>
445-
that matches the current one. If found with and without the <code>databaseId</code> the latter will be discarded.
442+
<code>databaseId</code>(3.5.5以上可用), 如果有一个配置好的 <code>DatabaseIdProvider</code>,
443+
MyBatis 会加载不带 <code>databaseId</code> 属性和带有匹配当前数据库 <code>databaseId</code> 属性的所有语句。如果同时存在带 <code>databaseId</code> 和不带 <code>databaseId</code> 属性的相同语句,则后者会被舍弃。
446444
</td>
447445
</tr>
448446
<tr>
@@ -470,9 +468,8 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
470468
(The <code>type</code> attribute is alias for <code>value</code>, you must be specify either one.
471469
But both attributes can be omit when specify the <code>defaultSqlProviderType</code> as global configuration)。
472470
<code>method</code> 用于指定该类的方法名(从版本 3.5.1 开始,可以省略 <code>method</code> 属性,MyBatis 将会使用 <code>ProviderMethodResolver</code> 接口解析方法的具体实现。如果解析失败,MyBatis 将会使用名为 <code>provideSql</code> 的降级实现)。<span class="label important">提示</span> 接下来的“SQL 语句构建器”一章将会讨论该话题,以帮助你以更清晰、更便于阅读的方式构建动态 SQL。
473-
<code>databaseId</code>(3.5.5 后可用), 假定有一个配置好的 <code>DatabaseIdProvider</code>,
474-
且若在注解中没有指定 <code>databaseId</code> 属性或者 <code>databaseId</code> 不与当前的方法匹配,MyBatis 将会使用它。
475-
If found with and without the <code>databaseId</code> the latter will be discarded.
471+
<code>databaseId</code>(3.5.5以上可用), 如果有一个配置好的 <code>DatabaseIdProvider</code>,
472+
MyBatis 会加载不带 <code>databaseId</code> 属性和带有匹配当前数据库 <code>databaseId</code> 属性的所有语句。如果同时存在带 <code>databaseId</code> 和不带 <code>databaseId</code> 属性的相同语句,则后者会被舍弃。
476473
</td>
477474
</tr>
478475
<tr>
@@ -487,9 +484,8 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
487484
<td><code>&lt;selectKey&gt;</code></td>
488485
       <td>
489486
这个注解的功能与 <code>&lt;selectKey&gt;</code> 标签完全一致。该注解只能在 <code>@Insert</code> 或 <code>@InsertProvider</code> 或 <code>@Update</code> 或 <code>@UpdateProvider</code> 标注的方法上使用,否则将会被忽略。如果标注了 <code>@SelectKey</code> 注解,MyBatis 将会忽略掉由 <code>@Options</code> 注解所设置的生成主键或设置(configuration)属性。属性:<code>statement</code> 以字符串数组形式指定将会被执行的 SQL 语句,<code>keyProperty</code> 指定作为参数传入的对象对应属性的名称,该属性将会更新成新的值,<code>before</code> 可以指定为 <code>true</code> 或 <code>false</code> 以指明 SQL 语句应被在插入语句的之前还是之后执行。<code>resultType</code> 则指定 <code>keyProperty</code> 的 Java 类型。<code>statementType</code> 则用于选择语句类型,可以选择 <code>STATEMENT</code>、<code>PREPARED</code> 或 <code>CALLABLE</code> 之一,它们分别对应于 <code>Statement</code>、<code>PreparedStatement</code> 和 <code>CallableStatement</code>。默认值是 <code>PREPARED</code>。
490-
<code>databaseId</code>(3.5.5 后可用), 假定有一个配置好的 <code>DatabaseIdProvider</code>,
491-
且若在注解中没有指定 <code>databaseId</code> 属性或者 <code>databaseId</code> 不与当前的方法匹配,MyBatis 将会使用它。
492-
If found with and without the <code>databaseId</code> the latter will be discarded.
487+
<code>databaseId</code>(3.5.5以上可用), 如果有一个配置好的 <code>DatabaseIdProvider</code>,
488+
MyBatis 会加载不带 <code>databaseId</code> 属性和带有匹配当前数据库 <code>databaseId</code> 属性的所有语句。如果同时存在带 <code>databaseId</code> 和不带 <code>databaseId</code> 属性的相同语句,则后者会被舍弃。
493489
</td>
494490
</tr>
495491
<tr>

0 commit comments

Comments
 (0)