Skip to content

Add some translations in java-api.xml #2527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 26 additions & 30 deletions src/site/zh/xdoc/java-api.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright 2009-2021 the original author or authors.
Copyright 2009-2022 the original author or authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -388,8 +388,8 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
       <td>复杂类型的单个属性映射。属性:
<code>select</code>,指定可加载合适类型实例的映射语句(也就是映射器方法)全限定名;
<code>fetchType</code>,指定在该映射中覆盖全局配置参数 <code>lazyLoadingEnabled</code>;
<code>resultMap</code>(available since 3.5.5), which is the fully qualified name of a result map that map to a single container object from select result;
<code>columnPrefix</code>(available since 3.5.5), which is column prefix for grouping select columns at nested result map.
<code>resultMap</code>3.5.5以上可用), which is the fully qualified name of a result map that map to a single container object from select result;
<code>columnPrefix</code>3.5.5以上可用),结果集的完全限定名,该结果映射到查询结果中的集合对象;
<span class="label important">提示</span> 注解 API 不支持联合映射。这是由于 Java 注解不允许产生循环引用。</td>
</tr>
<tr>
Expand All @@ -399,8 +399,8 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
       <td>复杂类型的集合属性映射。属性:
<code>select</code>,指定可加载合适类型实例集合的映射语句(也就是映射器方法)全限定名;
<code>fetchType</code>,指定在该映射中覆盖全局配置参数 <code>lazyLoadingEnabled</code>
<code>resultMap</code>(available since 3.5.5), which is the fully qualified name of a result map that map to collection object from select result
<code>columnPrefix</code>(available since 3.5.5), which is column prefix for grouping select columns at nested result map.
<code>resultMap</code>3.5.5以上可用),结果集的完全限定名,该结果映射到查询结果中的集合对象
<code>columnPrefix</code>3.5.5以上可用),在嵌套的结果集中对所查询的列进行分组的列前缀。
<span class="label important">提示</span> 注解 API 不支持联合映射。这是由于 Java 注解不允许产生循环引用。</td>
</tr>
<tr>
Expand All @@ -414,10 +414,9 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
<td><code>方法</code></td>
<td>映射语句的属性</td>
       <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> 注解,你的语句就会被上述属性的默认值所影响。要注意避免默认值带来的非预期行为。
The <code>databaseId</code>(Available since 3.5.5), in case there is a configured <code>DatabaseIdProvider</code>,
the MyBatis use the <code>Options</code> with no <code>databaseId</code> attribute or with a <code>databaseId</code>
that matches the current one. If found with and without the <code>databaseId</code> the latter will be discarded.<br/><br/>

<code>databaseId</code>(3.5.5以上可用), 如果有一个配置好的 <code>DatabaseIdProvider</code>,
MyBatis 会加载不带 <code>databaseId</code> 属性和带有匹配当前数据库 <code>databaseId</code> 属性的所有语句。如果同时存在带 <code>databaseId</code> 和不带 <code>databaseId</code> 属性的相同语句,则后者会被舍弃。<br/><br/>

       注意:<code>keyColumn</code> 属性只在某些数据库中有效(如 Oracle、PostgreSQL 等)。要了解更多关于 <code>keyColumn</code> 和 <code>keyProperty</code> 可选值信息,请查看“insert, update 和 delete”一节。</td>
</tr>
<tr>
Expand All @@ -440,9 +439,8 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
</td>
       <td>
每个注解分别代表将会被执行的 SQL 语句。它们用字符串数组(或单个字符串)作为参数。如果传递的是字符串数组,字符串数组会被连接成单个完整的字符串,每个字符串之间加入一个空格。这有效地避免了用 Java 代码构建 SQL 语句时产生的“丢失空格”问题。当然,你也可以提前手动连接好字符串。属性:<code>value</code>,指定用来组成单个 SQL 语句的字符串数组。
The <code>databaseId</code>(Available since 3.5.5), in case there is a configured <code>DatabaseIdProvider</code>,
the MyBatis use a statement with no <code>databaseId</code> attribute or with a <code>databaseId</code>
that matches the current one. If found with and without the <code>databaseId</code> the latter will be discarded.
<code>databaseId</code>(3.5.5以上可用), 如果有一个配置好的 <code>DatabaseIdProvider</code>,
MyBatis 会加载不带 <code>databaseId</code> 属性和带有匹配当前数据库 <code>databaseId</code> 属性的所有语句。如果同时存在带 <code>databaseId</code> 和不带 <code>databaseId</code> 属性的相同语句,则后者会被舍弃。
</td>
</tr>
<tr>
Expand Down Expand Up @@ -470,9 +468,8 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
(The <code>type</code> attribute is alias for <code>value</code>, you must be specify either one.
But both attributes can be omit when specify the <code>defaultSqlProviderType</code> as global configuration)。
<code>method</code> 用于指定该类的方法名(从版本 3.5.1 开始,可以省略 <code>method</code> 属性,MyBatis 将会使用 <code>ProviderMethodResolver</code> 接口解析方法的具体实现。如果解析失败,MyBatis 将会使用名为 <code>provideSql</code> 的降级实现)。<span class="label important">提示</span> 接下来的“SQL 语句构建器”一章将会讨论该话题,以帮助你以更清晰、更便于阅读的方式构建动态 SQL。
The <code>databaseId</code>(Available since 3.5.5), in case there is a configured <code>DatabaseIdProvider</code>,
the MyBatis will use a provider method with no <code>databaseId</code> attribute or with a <code>databaseId</code>
that matches the current one. If found with and without the <code>databaseId</code> the latter will be discarded.
<code>databaseId</code>(3.5.5以上可用), 如果有一个配置好的 <code>DatabaseIdProvider</code>,
MyBatis 会加载不带 <code>databaseId</code> 属性和带有匹配当前数据库 <code>databaseId</code> 属性的所有语句。如果同时存在带 <code>databaseId</code> 和不带 <code>databaseId</code> 属性的相同语句,则后者会被舍弃。
</td>
</tr>
<tr>
Expand All @@ -487,9 +484,8 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
<td><code>&lt;selectKey&gt;</code></td>
       <td>
这个注解的功能与 <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>。
The <code>databaseId</code>(Available since 3.5.5), in case there is a configured <code>DatabaseIdProvider</code>,
the MyBatis will use a statement with no <code>databaseId</code> attribute or with a <code>databaseId</code>
that matches the current one. If found with and without the <code>databaseId</code> the latter will be discarded.
<code>databaseId</code>(3.5.5以上可用), 如果有一个配置好的 <code>DatabaseIdProvider</code>,
MyBatis 会加载不带 <code>databaseId</code> 属性和带有匹配当前数据库 <code>databaseId</code> 属性的所有语句。如果同时存在带 <code>databaseId</code> 和不带 <code>databaseId</code> 属性的相同语句,则后者会被舍弃。
</td>
</tr>
<tr>
Expand Down Expand Up @@ -586,26 +582,26 @@ class UserSqlBuilder {
}
}]]></source>

<p>This example shows usage that share an sql provider class to all mapper methods using global configuration(Available since 3.5.6):</p>
<p>这是一个在全局配置下让所有映射方法在同一个 sql provider 类里面的例子(3.5.6 后可用):</p>
<source><![CDATA[
Configuration configuration = new Configuration();
configuration.setDefaultSqlProviderType(TemplateFilePathProvider.class); // Specify an sql provider class for sharing on all mapper methods
configuration.setDefaultSqlProviderType(TemplateFilePathProvider.class); // 让所有映射方法在同一个 sql provider 类里面
// ...]]></source>
<source><![CDATA[
// Can omit the type/value attribute on sql provider annotation
// If omit it, the MyBatis apply the class that specified on defaultSqlProviderType.
// 在 sql provider 注解上可以省略 type/value 属性
// 如果省略,MyBatis 将使用 defaultSqlProviderType 所指定的类
public interface UserMapper {

@SelectProvider // Same with @SelectProvider(TemplateFilePathProvider.class)
@SelectProvider // 等价于 @SelectProvider(TemplateFilePathProvider.class)
User findUser(int id);

@InsertProvider // Same with @InsertProvider(TemplateFilePathProvider.class)
@InsertProvider // 等价于 @InsertProvider(TemplateFilePathProvider.class)
void createUser(User user);

@UpdateProvider // Same with @UpdateProvider(TemplateFilePathProvider.class)
@UpdateProvider // 等价于 @UpdateProvider(TemplateFilePathProvider.class)
void updateUser(User user);

@DeleteProvider // Same with @DeleteProvider(TemplateFilePathProvider.class)
@DeleteProvider // 等价于 @DeleteProvider(TemplateFilePathProvider.class)
void deleteUser(int id);
}]]></source>

Expand All @@ -629,11 +625,11 @@ class UserSqlProvider implements ProviderMethodResolver {
}
}]]></source>

<p>This example shows usage the <code>databaseId</code> attribute on the statement annotation(Available since 3.5.5):</p>
<p>这个例子展现了如何在声明注解时使用<code>databaseId</code>属性(3.5.5后可用):</p>
<source><![CDATA[
@Select(value = "SELECT SYS_GUID() FROM dual", databaseId = "oracle") // Use this statement if DatabaseIdProvider provide "oracle"
@Select(value = "SELECT uuid_generate_v4()", databaseId = "postgres") // Use this statement if DatabaseIdProvider provide "postgres"
@Select("SELECT RANDOM_UUID()") // Use this statement if the DatabaseIdProvider not configured or not matches databaseId
@Select(value = "SELECT SYS_GUID() FROM dual", databaseId = "oracle") // 如果 DatabaseIdProvider 提供的是 "oracle",使用这条语句
@Select(value = "SELECT uuid_generate_v4()", databaseId = "postgres") // 如果 DatabaseIdProvider 提供的是 "postgres",使用这条语句
@Select("SELECT RANDOM_UUID()") // 如果 DatabaseIdProvider 没有配置或者没有对应的 databaseId, 使用这条语句
String generateId();
]]></source>

Expand Down