generator
generator copied to clipboard
Feature Request: template in generator configuration
for example I have many table share same config like below:
<table catalog="" schema="" tableName="PMS_PLAN" domainObjectName="Plan">
<property name="sea_locator" value="pms/plan" />
<property name="rootClass" value="fwx.commons.model.InputUpdateMetaData" />
<columnOverride column="IU" property="inputUser"></columnOverride>
<columnOverride column="IO" property="inputOrg"></columnOverride>
<columnOverride column="IT" property="inputTime"></columnOverride>
<columnOverride column="UU" property="updateUser"></columnOverride>
<columnOverride column="UO" property="updateOrg"></columnOverride>
<columnOverride column="UT" property="updateTime"></columnOverride>
</table>
can we define a template like this:
<template id="commonProperties">
<columnOverride column="IU" property="inputUser"></columnOverride>
<columnOverride column="IO" property="inputOrg"></columnOverride>
<columnOverride column="IT" property="inputTime"></columnOverride>
<columnOverride column="UU" property="updateUser"></columnOverride>
<columnOverride column="UO" property="updateOrg"></columnOverride>
<columnOverride column="UT" property="updateTime"></columnOverride>
<template>
then reference it like this:
<table catalog="" schema="" tableName="PMS_PLAN" domainObjectName="Plan">
<property name="sea_locator" value="pms/plan" />
<property name="rootClass" value="fwx.commons.model.InputUpdateMetaData" />
<templateRef id="commonProperties" />
</table>
for the xml dtd part, I think it will be easy to define a table template element which can have exact child elements of table element.
@jeffgbutler can you give me a hint which java class to work on, I want to contribute on this one .
@WestFarmer I think this is a good idea. However, I suggest implementing it a bit differently because it might be difficult to lookup the templateref
fragments with the current structure of the parser. I've thought about something like this:
<tableSet>
<table tableName="foo"/>
<table tableName="bar"/>
<columnOverride column="IU" property="inputUser"/>
<columnOverride column="IO" property="inputOrg"/>
<columnOverride column="IT" property="inputTime"/>
<columnOverride column="UU" property="updateUser"/>
<columnOverride column="UO" property="updateOrg"/>
<columnOverride column="UT" property="updateTime"/>
</tableSet>
What do you think of this idea?
The configuration parser is here: https://github.com/mybatis/generator/blob/master/core/mybatis-generator-core/src/main/java/org/mybatis/generator/config/xml/MyBatisGeneratorConfigurationParser.java
The DTD is here: https://github.com/mybatis/generator/blob/master/core/mybatis-generator-core/src/main/resources/org/mybatis/generator/config/xml/mybatis-generator-config_1_0.dtd
I think it's ok, will work on this. @jeffgbutler