Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions src/site/xdoc/configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1534,14 +1534,14 @@ public class ExamplePlugin implements Interceptor {
</p>

<source><![CDATA[SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader, environment);
SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader, environment,properties);]]></source>
SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader, environment, properties);]]></source>

<p>If the environment is omitted, then the default environment is
loaded, as follows:
</p>

<source><![CDATA[SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader);
SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader,properties);]]></source>
SqlSessionFactory factory = sqlSessionFactoryBuilder.build(reader, properties);]]></source>

<p>The environments element defines how the environment is
configured.
Expand Down Expand Up @@ -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 <code>databaseId</code> attribute.
MyBatis will load all statements with no <code>databaseId</code> attribute
or with a <code>databaseId</code> that matches the current one. If case the same statement
if found with and without the <code>databaseId</code> the latter will be discarded.
or with a <code>databaseId</code> that matches the current one. In case the same statement
is found with and without the <code>databaseId</code> the latter will be discarded.
To enable the multi vendor support add a <code>databaseIdProvider</code>
to mybatis-config.xml file as follows:
</p>
Expand Down Expand Up @@ -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 <code>file:///</code> URLs), class names or package names.
For example:
Expand Down
10 changes: 5 additions & 5 deletions src/site/xdoc/java-api.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ SqlSessionFactory factory = builder.build(configuration);</source>
<p>Now you have a SqlSessionFactory that can be used to create SqlSession instances.</p>

<h4>SqlSessionFactory</h4>
<p>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:</p>
<p>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:</p>
<ul>
<li><strong>Transaction</strong>: 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)?</li>
<li><strong>Connection</strong>: Do you want MyBatis to acquire a Connection from the configured DataSource for you, or do you want to provide your own?</li>
Expand Down Expand Up @@ -287,9 +287,9 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
<p>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.</p>
<p>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.</p>
<source><![CDATA[public interface AuthorMapper {
// (Author) selectOne("selectAuthor",5);
// (Author) selectOne("selectAuthor", 5);
Author selectAuthor(int id);
// (List<Author>) selectList(selectAuthors)
// (List<Author>) selectList("selectAuthors")
List<Author> selectAuthors();
// (Map<Integer,Author>) selectMap("selectAuthors", "id")
@MapKey("id")
Expand All @@ -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);
}]]></source>
<p>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.</p>
Expand Down Expand Up @@ -574,7 +574,7 @@ User getUserById(Integer id);
@Select("select * from company where id = #{id}")
Company getCompanyById(Integer id);</source>

<p>This example shows solo parameter using the Sql Provider annotation:</p>
<p>This example shows solo parameter using the SelectProvider annotation:</p>
<source><![CDATA[@SelectProvider(type = UserSqlBuilder.class, method = "buildGetUsersByName")
List<User> getUsersByName(String name);

Expand Down
18 changes: 9 additions & 9 deletions src/site/xdoc/sqlmap-xml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
</p>
Expand Down Expand Up @@ -541,7 +541,7 @@ ps.setInt(1,id);]]></source>
<p>
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:
</p>

<source><![CDATA[<select id="selectUsers" resultType="User">
Expand All @@ -552,7 +552,7 @@ ps.setInt(1,id);]]></source>

<p>
The example above demonstrates a very simple named parameter mapping. The parameterType is set to
<code>int</code>, so therefore the parameter could be named anything. Primitive or simply data types such as
<code>int</code>, so therefore the parameter could be named anything. Primitive or simple data types such as
<code>Integer</code> and <code>String</code> 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:
Expand Down Expand Up @@ -643,8 +643,8 @@ ps.setInt(1,id);]]></source>
<p>
By default, using the <code>#{}</code> syntax will cause MyBatis to generate <code>PreparedStatement</code> properties and
set the values safely against the <code>PreparedStatement</code> 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:
</p>

<source><![CDATA[ORDER BY ${columnName}]]></source>
Expand Down Expand Up @@ -731,7 +731,7 @@ public class User {
</select>]]></source>

<p>
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:
</p>

Expand Down Expand Up @@ -787,7 +787,7 @@ public class User {
</select>]]></source>

<p>
Now if only the world were always that simple.
Now if only the world was always that simple.
</p>

<h4>Advanced Result Maps</h4>
Expand Down Expand Up @@ -965,7 +965,7 @@ public class User {
<result property="subject" column="post_subject"/>]]></source>

<p>
These are the most basic of result mappings. Both <i>id</i>, and
These are the most basic of result mappings. Both <i>id</i> and
<i>result</i> map a single column value to a
single property or field of a simple data type (String, int, double, Date, etc.).
</p>
Expand Down Expand Up @@ -1756,7 +1756,7 @@ SELECT * FROM AUTHOR WHERE ID = #{id}]]></source>
<h4>Multiple ResultSets for Collection</h4>

<p>
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:
</p>

Expand Down
2 changes: 1 addition & 1 deletion src/site/xdoc/statement-builders.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ String sql = "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FULL_NAME, "
</subsection>
<subsection name="The Solution">
<p>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:
</p>

Expand Down