17
17
18
18
-->
19
19
<document xmlns =" http://maven.apache.org/XDOC/2.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
20
- xsi : schemaLocation =" http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd" >
20
+ xsi : schemaLocation =" http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd" >
21
21
22
22
<properties >
23
23
<title >MyBatis 3 | Configuration</title >
@@ -1583,19 +1583,19 @@ public class ExampleTypeHandler extends BaseTypeHandler<String> {
1583
1583
<li >Adding a <code >javaType</code > attribute to the typeHandler element (for example: <code >javaType="String"</code >)
1584
1584
</li >
1585
1585
<li >Adding a <code >@MappedTypes</code > annotation to your TypeHandler class specifying
1586
- the list of java types to associate it with. This annotation will be ignored if
1587
- the <code >javaType</code > attribute as also been specified.
1586
+ the list of java types to associate it with. This annotation will be ignored if
1587
+ the <code >javaType</code > attribute as also been specified.
1588
1588
</li >
1589
1589
</ul >
1590
1590
1591
1591
<p >The associated JDBC type can be specified by two means:</p >
1592
1592
<ul >
1593
1593
<li >
1594
- Adding a <code >jdbcType</code > attribute to the typeHandler element (for example: <code >jdbcType="VARCHAR"</code >).
1594
+ Adding a <code >jdbcType</code > attribute to the typeHandler element (for example: <code >jdbcType="VARCHAR"</code >).
1595
1595
</li >
1596
1596
<li >Adding a <code >@MappedJdbcTypes</code > annotation to your TypeHandler class specifying
1597
- the list of JDBC types to associate it with. This annotation will be ignored if
1598
- the <code >jdbcType</code > attribute as also been specified.
1597
+ the list of JDBC types to associate it with. This annotation will be ignored if
1598
+ the <code >jdbcType</code > attribute as also been specified.
1599
1599
</li >
1600
1600
</ul >
1601
1601
@@ -1642,32 +1642,32 @@ public class GenericTypeHandler<E extends MyObject> extends BaseTypeHandler<E> {
1642
1642
]]> </source >
1643
1643
1644
1644
<p ><code >EnumTypeHandler</code > and <code >EnumOrdinalTypeHandler</code > are generic TypeHandlers. We will learn
1645
- about them in the following section.
1645
+ about them in the following section.
1646
1646
</p >
1647
1647
1648
1648
</subsection >
1649
1649
1650
1650
<subsection name =" Handling Enums" >
1651
- <p >
1652
- If you want to map an <code >Enum</code >, you'll need to use either
1653
- <code >EnumTypeHandler</code > or <code >EnumOrdinalTypeHandler</code >.
1654
- </p >
1651
+ <p >
1652
+ If you want to map an <code >Enum</code >, you'll need to use either
1653
+ <code >EnumTypeHandler</code > or <code >EnumOrdinalTypeHandler</code >.
1654
+ </p >
1655
1655
1656
- <p >For example, let's say that we need to store the rounding mode that
1656
+ <p >For example, let's say that we need to store the rounding mode that
1657
1657
should be used with some number if it needs to be rounded. By default, MyBatis
1658
1658
uses <code >EnumTypeHandler</code > to convert the <code >Enum</code >
1659
1659
values to their names.
1660
- </p >
1660
+ </p >
1661
1661
1662
- <b >Note <code >EnumTypeHandler</code > is special in the sense that unlike other handlers,
1662
+ <b >Note <code >EnumTypeHandler</code > is special in the sense that unlike other handlers,
1663
1663
it does not handle just one specific class, but any class that extends <code >Enum</code ></b >
1664
1664
1665
- <p >However, we may not want to store names. Our DBA may insist on an
1665
+ <p >However, we may not want to store names. Our DBA may insist on an
1666
1666
integer code instead. That's just as easy: add <code >EnumOrdinalTypeHandler</code >
1667
1667
to the <code >typeHandlers</code > in your config file, and now each
1668
1668
<code >RoundingMode</code > will be mapped to an integer using its ordinal value.
1669
- </p >
1670
- <source ><![CDATA[ <!-- mybatis-config.xml -->
1669
+ </p >
1670
+ <source ><![CDATA[ <!-- mybatis-config.xml -->
1671
1671
<typeHandlers>
1672
1672
<typeHandler handler="org.apache.ibatis.type.EnumOrdinalTypeHandler"
1673
1673
javaType="java.math.RoundingMode"/>
@@ -1677,18 +1677,18 @@ public class GenericTypeHandler<E extends MyObject> extends BaseTypeHandler<E> {
1677
1677
But what if you want to map the same <code >Enum</code > to a
1678
1678
string in one place and to integer in another?
1679
1679
</p >
1680
- <p >
1681
- The auto-mapper will automatically use <code >EnumOrdinalTypeHandler</code >,
1682
- so if we want to go back to using plain old ordinary
1683
- <code >EnumTypeHandler</code >, we have to tell it, by explicitly setting
1684
- the type handler to use for those SQL statements.
1685
- </p >
1686
- <p >
1687
- (Mapper files aren't covered until the next section, so if this is your first
1688
- time reading through the documentation, you may want to skip this for now
1689
- and come back to it later.)
1690
- </p >
1691
- <source ><![CDATA[ <!DOCTYPE mapper
1680
+ <p >
1681
+ The auto-mapper will automatically use <code >EnumOrdinalTypeHandler</code >,
1682
+ so if we want to go back to using plain old ordinary
1683
+ <code >EnumTypeHandler</code >, we have to tell it, by explicitly setting
1684
+ the type handler to use for those SQL statements.
1685
+ </p >
1686
+ <p >
1687
+ (Mapper files aren't covered until the next section, so if this is your first
1688
+ time reading through the documentation, you may want to skip this for now
1689
+ and come back to it later.)
1690
+ </p >
1691
+ <source ><![CDATA[ <!DOCTYPE mapper
1692
1692
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
1693
1693
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
1694
1694
@@ -2218,7 +2218,7 @@ public class C3P0DataSourceFactory extends UnpooledDataSourceFactory {
2218
2218
}]]> </source >
2219
2219
2220
2220
<p >To set it up, add a property for each setter method you want MyBatis to call.
2221
- Follows below a sample configuration which connects to a PostgreSQL database:</p >
2221
+ Follows below a sample configuration which connects to a PostgreSQL database:</p >
2222
2222
2223
2223
<source ><![CDATA[ <dataSource type="org.myproject.C3P0DataSourceFactory">
2224
2224
<property name="driver" value="org.postgresql.Driver"/>
0 commit comments