本篇文章为你整理了MyBatis Generator Core – MyBatis Generator XML Configuration File Reference()的详细内容,包含有 MyBatis Generator Core – MyBatis Generator XML Configuration File Reference,希望能帮助你了解 MyBatis Generator Core – MyBatis Generator XML Configuration File Reference。
In the most common use case, MyBatis Generator (MBG) is driven by an XML
configuration file. The configuration file tells MBG:
The following is an example MBG configuration file. See the individual pages
for each element for more information about the elements and the values of the
attributes.
!DOCTYPE generatorConfiguration
PUBLIC -//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN
http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd
generatorConfiguration
classPathEntry location= /Program Files/IBM/SQLLIB/java/db2java.zip /
context id= DB2Tables targetRuntime= MyBatis3
jdbcConnection driver >
Important notes about this file follow:
The file specifies that the legacy DB2 CLI driver will be used to connect to the database,
and also specifies where the driver can be found.
The Java Type Resolver should not force the use of BigDecimal fields - this means that
integral types (Short, Integer, Long, etc.) will be substituted if possible. This feature
is an attempt to make database DECIMAL and NUMERIC columns easier to deal with.
The Java model generator should use sub-packages. This means that the generated model
objects will be placed in a package called test.model.db2admin in this case
(because the table
is in the DB2ADMIN schema). If the enableSubPackages attribute was set to
false,
then the package would be test.model. The Java model generator should
also trim strings.
This means that the setters for any String properties will call the trim
function -
this is useful if your database might return blank characters at the end of character
columns.
The SQL Map generator should use sub-packages. This means that the generated XML files
will be placed in a package called test.xml.db2admin in this case
(because the table
is in the DB2ADMIN schema). If the enableSubPackages attribute was set
to false,
then the package would be test.xml.
The DAO generator should use sub-packages. This means that the generated DAO classes
will be placed in a package called test.dao.db2admin in this case
(because the table
is in the DB2ADMIN schema). If the enableSubPackages attribute was set
to false,
then the package would be test.dao. The DAO generator should generate
mapper interfaces that reference an XML configuration for MyBatis.
The file specifies only one table will be introspected, but many more could be specified.
Important notes about the specified table include:
Actual column names will be used as properties. If this property were set to
false (or not specified), then MBG would attempt to camel case
the column
names. In either case, the name can be overridden by the
columnOverride
element
The column has a generated key, it is an identity column, and the database type is DB2.
This will cause
MBG to generate the proper
selectKey element in the generated
insert
statement so that the newly generated key can be returned (using DB2 specific SQL).
The column DATE_FIELD will be mapped to a property called
startDate. This will
override the default property which would be
DATE_FIELD in this case, or dateField
if the useActualColumnNames property was set to
false.
The column FRED will be ignored. No SQL will list the field,
and no Java property will be generated.
The column LONG_VARCHAR_FIELD will be treated as a
VARCHAR field, regardless of the actual data type.
以上就是MyBatis Generator Core – MyBatis Generator XML Configuration File Reference()的详细内容,想要了解更多 MyBatis Generator Core – MyBatis Generator XML Configuration File Reference的内容,请持续关注盛行IT软件开发工作室。
郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。