From d6918e1f9e1784a89a53730a59b251d88b31532b Mon Sep 17 00:00:00 2001 From: Anatolii Stepaniuk Date: Fri, 30 Sep 2016 16:04:32 +0300 Subject: [PATCH 1/7] added missed space added missed space --- src/site/xdoc/configuration.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/xdoc/configuration.xml b/src/site/xdoc/configuration.xml index ff751dc4496..da94abe67ed 100644 --- a/src/site/xdoc/configuration.xml +++ b/src/site/xdoc/configuration.xml @@ -1534,7 +1534,7 @@ public class ExamplePlugin implements Interceptor {

+SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader, environment, properties);]]>

If the environment is omitted, then the default environment is loaded, as follows: From 58d46df30bd356f3b4a6e008f60d038fa6705cab Mon Sep 17 00:00:00 2001 From: Anatolii Stepaniuk Date: Fri, 30 Sep 2016 16:13:29 +0300 Subject: [PATCH 2/7] fixed typos in documentation fixed typos in documentation --- src/site/xdoc/configuration.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/site/xdoc/configuration.xml b/src/site/xdoc/configuration.xml index da94abe67ed..7df0b512e82 100644 --- a/src/site/xdoc/configuration.xml +++ b/src/site/xdoc/configuration.xml @@ -1541,7 +1541,7 @@ SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader, environment,

+SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader, properties);]]>

The environments element defines how the environment is configured. @@ -1841,8 +1841,8 @@ public class C3P0DataSourceFactory extends UnpooledDataSourceFactory { MyBatis is able to execute different statements depending on your database vendor. The multi-db vendor support is based on the mapped statements databaseId attribute. MyBatis will load all statements with no databaseId attribute - or with a databaseId that matches the current one. If case the same statement - if found with and without the databaseId the latter will be discarded. + or with a databaseId that matches the current one. In case the same statement + is found with and without the databaseId the latter will be discarded. To enable the multi vendor support add a databaseIdProvider to mybatis-config.xml file as follows:

@@ -1888,7 +1888,7 @@ public class C3P0DataSourceFactory extends UnpooledDataSourceFactory { statements. But first, we need to tell MyBatis where to find them. Java doesn’t really provide any good means of auto-discovery in this regard, so the best way to do it is to simply tell MyBatis - where to find the mapping files. You can use class path relative + where to find the mapping files. You can use classpath relative resource references, fully qualified url references (including file:/// URLs), class names or package names. For example: From 4678bb093725272123428c17fb73947aac86b58e Mon Sep 17 00:00:00 2001 From: Anatolii Stepaniuk Date: Fri, 30 Sep 2016 16:53:14 +0300 Subject: [PATCH 3/7] fixed some errors in documentation fixed some errors in documentation --- src/site/xdoc/sqlmap-xml.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/site/xdoc/sqlmap-xml.xml b/src/site/xdoc/sqlmap-xml.xml index ad0f04bb0c7..e58ed385baa 100755 --- a/src/site/xdoc/sqlmap-xml.xml +++ b/src/site/xdoc/sqlmap-xml.xml @@ -85,7 +85,7 @@ The select statement is one of the most popular elements that you'll use in MyBatis. Putting data in a database isn't terribly valuable until you get it back out, so most applications query far more than they modify the data. For every insert, update or delete, - there is probably many selects. This is one of the founding principles of MyBatis, and is the + there are probably many selects. This is one of the founding principles of MyBatis, and is the reason so much focus and effort was placed on querying and result mapping. The select element is quite simple for simple cases. For example:

@@ -541,7 +541,7 @@ ps.setInt(1,id);]]>

In all of the past statements, you've seen examples of simple parameters. Parameters are very powerful elements in MyBatis. For simple situations, probably 90% of the cases, there's not much - too them, for example: + to them, for example:

@@ -552,7 +552,7 @@ ps.setInt(1,id);]]>

The example above demonstrates a very simple named parameter mapping. The parameterType is set to - int, so therefore the parameter could be named anything. Primitive or simply data types such as + int, so therefore the parameter could be named anything. Primitive or simple data types such as Integer and String have no relevant properties, and thus will replace the full value of the parameter entirely. However, if you pass in a complex object, then the behavior is a little different. For example: @@ -643,8 +643,8 @@ ps.setInt(1,id);]]>

By default, using the #{} syntax will cause MyBatis to generate PreparedStatement properties and set the values safely against the PreparedStatement parameters (e.g. ?). While this is safer, - faster and almost always preferred, sometimes you just want to directly inject a string - unmodified into the SQL Statement. For example, for ORDER BY, you might use something like this: + faster and almost always preferred, sometimes you just want to directly inject an unmodified string + into the SQL Statement. For example, for ORDER BY, you might use something like this:

@@ -731,7 +731,7 @@ public class User { ]]>

- And remember that TypeAliases are your friend. Use them so that you don't have to keep typing the + And remember that TypeAliases are your friends. Use them so that you don't have to keep typing the fully qualified path of your class out. For example:

@@ -787,7 +787,7 @@ public class User { ]]>

- Now if only the world were always that simple. + Now if only the world was always that simple.

Advanced Result Maps

@@ -965,7 +965,7 @@ public class User { ]]>

- These are the most basic of result mappings. Both id, and + These are the most basic of result mappings. Both id and result map a single column value to a single property or field of a simple data type (String, int, double, Date, etc.).

From 9e442180aad9177bffd3b78db7aa1c4b9827d01e Mon Sep 17 00:00:00 2001 From: Anatolii Stepaniuk Date: Fri, 30 Sep 2016 17:38:49 +0300 Subject: [PATCH 4/7] small improvement to documentation small improvement to documentation --- src/site/xdoc/sqlmap-xml.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/xdoc/sqlmap-xml.xml b/src/site/xdoc/sqlmap-xml.xml index e58ed385baa..4b22105c8c7 100755 --- a/src/site/xdoc/sqlmap-xml.xml +++ b/src/site/xdoc/sqlmap-xml.xml @@ -1756,7 +1756,7 @@ SELECT * FROM AUTHOR WHERE ID = #{id}]]>

Multiple ResultSets for Collection

- As we did for the association, we can call an stored procedure that executes two queries and returns two result sets, one with Blogs + As we did for the association, we can call a stored procedure that executes two queries and returns two result sets, one with Blogs and another with Posts:

From e29c5de20851fd0bb932ec47bd2a9c72bf611688 Mon Sep 17 00:00:00 2001 From: Anatolii Stepaniuk Date: Fri, 30 Sep 2016 18:25:36 +0300 Subject: [PATCH 5/7] added missed space http://www.mybatis.org/mybatis-3/java-api.html --- src/site/xdoc/java-api.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/xdoc/java-api.xml b/src/site/xdoc/java-api.xml index 1ba6122558d..298698277dd 100644 --- a/src/site/xdoc/java-api.xml +++ b/src/site/xdoc/java-api.xml @@ -146,7 +146,7 @@ SqlSessionFactory factory = builder.build(configuration);

Now you have a SqlSessionFactory that can be used to create SqlSession instances.

SqlSessionFactory

-

SqlSessionFactory has six methods that are used to create SqlSessionInstances. In general, the decisions you'll be making when selecting one of these methods are:

+

SqlSessionFactory has six methods that are used to create SqlSession instances. In general, the decisions you'll be making when selecting one of these methods are:

  • Transaction: Do you want to use a transaction scope for the session, or use auto-commit (usually means no transaction with most databases and/or JDBC drivers)?
  • Connection: Do you want MyBatis to acquire a Connection from the configured DataSource for you, or do you want to provide your own?
  • From 7ea908f7bd7437e50e880da5639f6830ae5f79ec Mon Sep 17 00:00:00 2001 From: Anatolii Stepaniuk Date: Sat, 1 Oct 2016 21:05:16 +0300 Subject: [PATCH 6/7] fixed a few uncertainties in documentations --- src/site/xdoc/java-api.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/site/xdoc/java-api.xml b/src/site/xdoc/java-api.xml index 298698277dd..13a47ec537f 100644 --- a/src/site/xdoc/java-api.xml +++ b/src/site/xdoc/java-api.xml @@ -287,9 +287,9 @@ try (SqlSession session = sqlSessionFactory.openSession()) {

    While the various insert, update, delete and select methods above are powerful, they are also very verbose, not type safe and not as helpful to your IDE or unit tests as they could be. We've already seen an example of using Mappers in the Getting Started section above.

    Therefore, a more common way to execute mapped statements is to use Mapper classes. A mapper class is simply an interface with method definitions that match up against the SqlSession methods. The following example class demonstrates some method signatures and how they map to the SqlSession.

    ) selectList(“selectAuthors”) + // (List) selectList("selectAuthors") List selectAuthors(); // (Map) selectMap("selectAuthors", "id") @MapKey("id") @@ -298,7 +298,7 @@ try (SqlSession session = sqlSessionFactory.openSession()) { int insertAuthor(Author author); // updateAuthor("updateAuthor", author) int updateAuthor(Author author); - // delete("deleteAuthor",5) + // delete("deleteAuthor", 5) int deleteAuthor(int id); }]]>

    In a nutshell, each Mapper method signature should match that of the SqlSession method that it's associated to, but without the String parameter ID. Instead, the method name must match the mapped statement ID.

    @@ -574,7 +574,7 @@ User getUserById(Integer id); @Select("select * from company where id = #{id}") Company getCompanyById(Integer id); -

    This example shows solo parameter using the Sql Provider annotation:

    +

    This example shows solo parameter using the SelectProvider annotation:

    getUsersByName(String name); From 7f40414e44272e754179e45f7d605b4b49396681 Mon Sep 17 00:00:00 2001 From: Anatolii Stepaniuk Date: Sat, 1 Oct 2016 21:12:13 +0300 Subject: [PATCH 7/7] added "that" word for clarity --- src/site/xdoc/statement-builders.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/xdoc/statement-builders.xml b/src/site/xdoc/statement-builders.xml index 43df5225d55..3d438d1172e 100644 --- a/src/site/xdoc/statement-builders.xml +++ b/src/site/xdoc/statement-builders.xml @@ -52,7 +52,7 @@ String sql = "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FULL_NAME, "

    MyBatis 3 offers a convenient utility class to help with the problem. - With the SQL class, you simply create an instance lets you call methods against it to build a SQL statement + With the SQL class, you simply create an instance that lets you call methods against it to build a SQL statement one step at a time. The example problem above would look like this when rewritten with the SQL class: