Skip to content

Commit d59f98d

Browse files
authored
Merge pull request #979 from hazendaz/master
[pdf] Polishing pdf doc by reducing some warnings during generation
2 parents 32bf5f8 + 3272df4 commit d59f98d

File tree

2 files changed

+138
-139
lines changed

2 files changed

+138
-139
lines changed

src/site/xdoc/configuration.xml

Lines changed: 111 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
44
Copyright 2009-2017 the original author or authors.
@@ -96,11 +96,13 @@
9696
methods. For
9797
example:
9898
</p>
99-
<source><![CDATA[SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(reader, props);
99+
<source><![CDATA[SqlSessionFactory factory =
100+
sqlSessionFactoryBuilder.build(reader, props);
100101
101102
// ... or ...
102103
103-
SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(reader, environment, props);
104+
SqlSessionFactory factory =
105+
new SqlSessionFactoryBuilder.build(reader, environment, props);
104106
]]></source>
105107
<p>
106108
If a property exists in more than one of these places, MyBatis
@@ -638,7 +640,8 @@ SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(reader, environ
638640
<setting name="mapUnderscoreToCamelCase" value="false"/>
639641
<setting name="localCacheScope" value="SESSION"/>
640642
<setting name="jdbcTypeForNull" value="OTHER"/>
641-
<setting name="lazyLoadTriggerMethods" value="equals,clone,hashCode,toString"/>
643+
<setting name="lazyLoadTriggerMethods"
644+
value="equals,clone,hashCode,toString"/>
642645
</settings>]]></source>
643646

644647
</subsection>
@@ -1248,22 +1251,26 @@ public class Author {
12481251
public class ExampleTypeHandler extends BaseTypeHandler<String> {
12491252
12501253
@Override
1251-
public void setNonNullParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) throws SQLException {
1254+
public void setNonNullParameter(PreparedStatement ps, int i,
1255+
String parameter, JdbcType jdbcType) throws SQLException {
12521256
ps.setString(i, parameter);
12531257
}
12541258
12551259
@Override
1256-
public String getNullableResult(ResultSet rs, String columnName) throws SQLException {
1260+
public String getNullableResult(ResultSet rs, String columnName)
1261+
throws SQLException {
12571262
return rs.getString(columnName);
12581263
}
12591264
12601265
@Override
1261-
public String getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
1266+
public String getNullableResult(ResultSet rs, int columnIndex)
1267+
throws SQLException {
12621268
return rs.getString(columnIndex);
12631269
}
12641270
12651271
@Override
1266-
public String getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
1272+
public String getNullableResult(CallableStatement cs, int columnIndex)
1273+
throws SQLException {
12671274
return cs.getString(columnIndex);
12681275
}
12691276
}
@@ -1351,53 +1358,54 @@ public class GenericTypeHandler<E extends MyObject> extends BaseTypeHandler<E> {
13511358
...
13521359
]]></source>
13531360

1354-
<p><code>EnumTypeHandler</code> and <code>EnumOrdinalTypeHandler</code> are generic TypeHandlers. We will learn
1355-
about them in the following section.
1356-
</p>
1361+
<p><code>EnumTypeHandler</code> and <code>EnumOrdinalTypeHandler</code> are generic TypeHandlers. We will learn
1362+
about them in the following section.
1363+
</p>
13571364

13581365
</subsection>
13591366

13601367
<subsection name="Handling Enums">
1361-
<p>
1362-
If you want to map an <code>Enum</code>, you'll need to use either
1363-
<code>EnumTypeHandler</code> or <code>EnumOrdinalTypeHandler</code>.
1364-
</p>
1365-
1366-
<p>For example, let's say that we need to store the rounding mode that
1367-
should be used with some number if it needs to be rounded. By default, MyBatis
1368-
uses <code>EnumTypeHandler</code> to convert the <code>Enum</code>
1369-
values to their names.
1370-
</p>
1371-
1372-
<b>Note <code>EnumTypeHandler</code> is special in the sense that unlike other handlers,
1373-
it does not handle just one specific class, but any class that extends <code>Enum</code></b>
1374-
1375-
<p>However, we may not want to store names. Our DBA may insist on an
1376-
integer code instead. That's just as easy: add <code>EnumOrdinalTypeHandler</code>
1377-
to the <code>typeHandlers</code> in your config file, and now each
1378-
<code>RoundingMode</code> will be mapped to an integer using its ordinal value.
1379-
</p>
1368+
<p>
1369+
If you want to map an <code>Enum</code>, you'll need to use either
1370+
<code>EnumTypeHandler</code> or <code>EnumOrdinalTypeHandler</code>.
1371+
</p>
1372+
1373+
<p>For example, let's say that we need to store the rounding mode that
1374+
should be used with some number if it needs to be rounded. By default, MyBatis
1375+
uses <code>EnumTypeHandler</code> to convert the <code>Enum</code>
1376+
values to their names.
1377+
</p>
1378+
1379+
<b>Note <code>EnumTypeHandler</code> is special in the sense that unlike other handlers,
1380+
it does not handle just one specific class, but any class that extends <code>Enum</code></b>
1381+
1382+
<p>However, we may not want to store names. Our DBA may insist on an
1383+
integer code instead. That's just as easy: add <code>EnumOrdinalTypeHandler</code>
1384+
to the <code>typeHandlers</code> in your config file, and now each
1385+
<code>RoundingMode</code> will be mapped to an integer using its ordinal value.
1386+
</p>
13801387
<source><![CDATA[<!-- mybatis-config.xml -->
13811388
<typeHandlers>
1382-
<typeHandler handler="org.apache.ibatis.type.EnumOrdinalTypeHandler" javaType="java.math.RoundingMode"/>
1389+
<typeHandler handler="org.apache.ibatis.type.EnumOrdinalTypeHandler"
1390+
javaType="java.math.RoundingMode"/>
13831391
</typeHandlers>
13841392
]]></source>
1385-
<p>
1386-
But what if you want to map the same <code>Enum</code> to a
1387-
string in one place and to integer in another?
1388-
</p>
1389-
<p>
1390-
The auto-mapper will automatically use <code>EnumOrdinalTypeHandler</code>,
1391-
so if we want to go back to using plain old ordinary
1392-
<code>EnumTypeHandler</code>, we have to tell it, by explicitly setting
1393-
the type handler to use for those SQL statements.
1394-
</p>
1395-
<p>
1396-
(Mapper files aren't covered until the next section, so if this is your first
1397-
time reading through the documentation, you may want to skip this for now
1398-
and come back to it later.)
1399-
</p>
1400-
<source><![CDATA[<!DOCTYPE mapper
1393+
<p>
1394+
But what if you want to map the same <code>Enum</code> to a
1395+
string in one place and to integer in another?
1396+
</p>
1397+
<p>
1398+
The auto-mapper will automatically use <code>EnumOrdinalTypeHandler</code>,
1399+
so if we want to go back to using plain old ordinary
1400+
<code>EnumTypeHandler</code>, we have to tell it, by explicitly setting
1401+
the type handler to use for those SQL statements.
1402+
</p>
1403+
<p>
1404+
(Mapper files aren't covered until the next section, so if this is your first
1405+
time reading through the documentation, you may want to skip this for now
1406+
and come back to it later.)
1407+
</p>
1408+
<source><![CDATA[<!DOCTYPE mapper
14011409
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
14021410
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
14031411
@@ -1406,43 +1414,44 @@ public class GenericTypeHandler<E extends MyObject> extends BaseTypeHandler<E> {
14061414
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
14071415
14081416
<mapper namespace="org.apache.ibatis.submitted.rounding.Mapper">
1409-
<resultMap type="org.apache.ibatis.submitted.rounding.User" id="usermap">
1410-
<id column="id" property="id"/>
1411-
<result column="name" property="name"/>
1412-
<result column="funkyNumber" property="funkyNumber"/>
1413-
<result column="roundingMode" property="roundingMode"/>
1414-
</resultMap>
1415-
1416-
<select id="getUser" resultMap="usermap">
1417-
select * from users
1418-
</select>
1419-
<insert id="insert">
1420-
insert into users (id, name, funkyNumber, roundingMode) values (
1421-
#{id}, #{name}, #{funkyNumber}, #{roundingMode}
1422-
)
1423-
</insert>
1424-
1425-
<resultMap type="org.apache.ibatis.submitted.rounding.User" id="usermap2">
1426-
<id column="id" property="id"/>
1427-
<result column="name" property="name"/>
1428-
<result column="funkyNumber" property="funkyNumber"/>
1429-
<result column="roundingMode" property="roundingMode" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/>
1430-
</resultMap>
1431-
<select id="getUser2" resultMap="usermap2">
1432-
select * from users2
1433-
</select>
1434-
<insert id="insert2">
1435-
insert into users2 (id, name, funkyNumber, roundingMode) values (
1436-
#{id}, #{name}, #{funkyNumber}, #{roundingMode, typeHandler=org.apache.ibatis.type.EnumTypeHandler}
1437-
)
1438-
</insert>
1417+
<resultMap type="org.apache.ibatis.submitted.rounding.User" id="usermap">
1418+
<id column="id" property="id"/>
1419+
<result column="name" property="name"/>
1420+
<result column="funkyNumber" property="funkyNumber"/>
1421+
<result column="roundingMode" property="roundingMode"/>
1422+
</resultMap>
1423+
1424+
<select id="getUser" resultMap="usermap">
1425+
select * from users
1426+
</select>
1427+
<insert id="insert">
1428+
insert into users (id, name, funkyNumber, roundingMode) values (
1429+
#{id}, #{name}, #{funkyNumber}, #{roundingMode}
1430+
)
1431+
</insert>
1432+
1433+
<resultMap type="org.apache.ibatis.submitted.rounding.User" id="usermap2">
1434+
<id column="id" property="id"/>
1435+
<result column="name" property="name"/>
1436+
<result column="funkyNumber" property="funkyNumber"/>
1437+
<result column="roundingMode" property="roundingMode"
1438+
typeHandler="org.apache.ibatis.type.EnumTypeHandler"/>
1439+
</resultMap>
1440+
<select id="getUser2" resultMap="usermap2">
1441+
select * from users2
1442+
</select>
1443+
<insert id="insert2">
1444+
insert into users2 (id, name, funkyNumber, roundingMode) values (
1445+
#{id}, #{name}, #{funkyNumber}, #{roundingMode, typeHandler=org.apache.ibatis.type.EnumTypeHandler}
1446+
)
1447+
</insert>
14391448
14401449
</mapper>
14411450
]]></source>
1442-
<p>
1443-
Note that this forces us to use a <code>resultMap</code>
1444-
instead of a <code>resultType</code> in our select statements.
1445-
</p>
1451+
<p>
1452+
Note that this forces us to use a <code>resultMap</code>
1453+
instead of a <code>resultType</code> in our select statements.
1454+
</p>
14461455
</subsection>
14471456

14481457
<subsection name="objectFactory">
@@ -1878,19 +1887,19 @@ SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(reader, propert
18781887
constructor of the InitialContext upon instantiation.
18791888
</p>
18801889

1881-
<p>
1882-
You can plug any 3rd party DataSource by implementing the interface <code>org.apache.ibatis.datasource.DataSourceFactory</code>:
1883-
</p>
1890+
<p>
1891+
You can plug any 3rd party DataSource by implementing the interface <code>org.apache.ibatis.datasource.DataSourceFactory</code>:
1892+
</p>
18841893

18851894
<source><![CDATA[public interface DataSourceFactory {
18861895
void setProperties(Properties props);
18871896
DataSource getDataSource();
18881897
}]]></source>
18891898

18901899
<p>
1891-
<code>org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory</code> can be used as super class
1892-
to build new datasource adapters. For example this is the code needed to plug C3P0:
1893-
</p>
1900+
<code>org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory</code> can be used as super class
1901+
to build new datasource adapters. For example this is the code needed to plug C3P0:
1902+
</p>
18941903

18951904
<source><![CDATA[import org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory;
18961905
import com.mchange.v2.c3p0.ComboPooledDataSource;
@@ -1929,29 +1938,29 @@ public class C3P0DataSourceFactory extends UnpooledDataSourceFactory {
19291938
<source><![CDATA[<databaseIdProvider type="DB_VENDOR" />
19301939
]]></source>
19311940

1932-
<p>
1933-
The DB_VENDOR implementation databaseIdProvider sets as databaseId the String returned by
1934-
<code>DatabaseMetaData#getDatabaseProductName()</code>.
1935-
Given that usually that string is too long and that different versions of the same product may return different values,
1936-
you may want to convert it to a shorter one by adding properties like follows:
1937-
</p>
1941+
<p>
1942+
The DB_VENDOR implementation databaseIdProvider sets as databaseId the String returned by
1943+
<code>DatabaseMetaData#getDatabaseProductName()</code>.
1944+
Given that usually that string is too long and that different versions of the same product may return different values,
1945+
you may want to convert it to a shorter one by adding properties like follows:
1946+
</p>
19381947

19391948
<source><![CDATA[<databaseIdProvider type="DB_VENDOR">
19401949
<property name="SQL Server" value="sqlserver"/>
19411950
<property name="DB2" value="db2"/>
19421951
<property name="Oracle" value="oracle" />
19431952
</databaseIdProvider>]]></source>
19441953

1945-
<p>
1946-
When properties are provided, the DB_VENDOR databaseIdProvider will search the property value corresponding to the
1947-
first key found in the returned database product name or "null" if there is not a matching property.
1948-
In this case, if <code>getDatabaseProductName()</code> returns "Oracle (DataDirect)" the databaseId will be set to "oracle".
1949-
</p>
1954+
<p>
1955+
When properties are provided, the DB_VENDOR databaseIdProvider will search the property value corresponding to the
1956+
first key found in the returned database product name or "null" if there is not a matching property.
1957+
In this case, if <code>getDatabaseProductName()</code> returns "Oracle (DataDirect)" the databaseId will be set to "oracle".
1958+
</p>
19501959

1951-
<p>
1952-
You can build your own DatabaseIdProvider by implementing the interface <code>org.apache.ibatis.mapping.DatabaseIdProvider</code>
1953-
and registering it in mybatis-config.xml:
1954-
</p>
1960+
<p>
1961+
You can build your own DatabaseIdProvider by implementing the interface <code>org.apache.ibatis.mapping.DatabaseIdProvider</code>
1962+
and registering it in mybatis-config.xml:
1963+
</p>
19551964

19561965
<source><![CDATA[public interface DatabaseIdProvider {
19571966
void setProperties(Properties p);

0 commit comments

Comments
 (0)