diff --git a/src/site/zh/xdoc/sqlmap-xml.xml b/src/site/zh/xdoc/sqlmap-xml.xml index 97828a83896..c1cd03e4407 100644 --- a/src/site/zh/xdoc/sqlmap-xml.xml +++ b/src/site/zh/xdoc/sqlmap-xml.xml @@ -1804,30 +1804,30 @@ MyBatis 会从结果集中得到每条记录, - +

- As you have already seen in the previous sections, in simple cases MyBatis can auto-map the results for you - and in others you will need to build a result map. - But as you will see in this section you can also mix both strategies. - Let's have a deeper look at how auto-mapping works. + 正如你在前面一节看到的,在简单的场景下,MyBatis可以替你自动映射查询结果。 + 如果遇到复杂的场景,你需要构建一个result map。 + 但是在本节你将看到,你也可以混合使用这两种策略。 + 让我们到深一点的层面上看看自动映射是怎样工作的。

- When auto-mapping results MyBatis will get the column name and look for a property with the same name ignoring case. That means that if - a column named ID and property named id are found, MyBatis will set the id property with the ID column value. + 当自动映射查询结果时,MyBatis会获取sql返回的列名并在java类中查找相同名字的属性(忽略大小写)。 + 这意味着如果Mybatis发现了ID列和id属性,Mybatis会将ID的值赋给id

- Usually database columns are named using uppercase letters and underscores between words and java properties often follow the camelcase - naming covention. To enable the auto-mapping between them set the setting mapUnderscoreToCamelCase to true. + 通常数据库列使用大写单词命名,单词间用下划线分隔;而java属性一般遵循驼峰命名法。 + 为了在这两种命名方式之间启用自动映射,需要将 mapUnderscoreToCamelCase设置为true。

- Auto-mapping works even when there is an specific result map. When this happens, for each result map, all columns that are present in the - ResultSet that have not a manual mapping will be auto-mapped, then manual mappings will be processed. - In the following sample id and userName columns will be auto-mapped and hashed_password column will be mapped.

- + 自动映射甚至在特定的result map下也能工作。在这种情况下,对于每一个result map,所有的ResultSet提供的列, + 如果没有被手工映射,则将被自动映射。自动映射处理完毕后手工映射才会被处理。 + 在接下来的例子中, iduserName列将被自动映射, hashed_password 列将根据配置映射。 +

select user_id as "id",