(メッセージはありません)
@@ -1,30 +1,33 @@ | ||
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | 2 | <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> |
3 | 3 | <generatorConfiguration> |
4 | - <context id="context1" targetRuntime="MyBatis3"> | |
5 | - <plugin type="AddSuffixEntityPlugin" /> | |
6 | - <plugin type="WithoutLockPlugin" /> | |
4 | + <context id="context1" targetRuntime="MyBatis3"> | |
5 | + <plugin type="AddSuffixEntityPlugin" /> | |
6 | + <plugin type="WithoutLockPlugin" /> | |
7 | 7 | <plugin type="org.mybatis.generator.plugins.SerializablePlugin" /> |
8 | - <plugin type="org.mybatis.generator.plugins.ToStringPlugin" /> | |
9 | - | |
10 | - <commentGenerator> | |
11 | - <property name="suppressAllComments" value="true" /> | |
12 | - </commentGenerator> | |
13 | - <jdbcConnection driverClass="org.postgresql.Driver" | |
14 | - connectionURL="jdbc:postgresql://localhost/dvdrental" | |
15 | - userId="postgres" password="postgres" /> | |
16 | - <javaModelGenerator targetPackage="test.postgres" | |
17 | - targetProject="mybatisPlugins/src"> | |
18 | - <property name="trimStrings" value="true" /> | |
19 | - <property name="constructorBased" value="true" /> | |
20 | - </javaModelGenerator> | |
21 | - <sqlMapGenerator targetPackage="test.postgres" | |
22 | - targetProject="mybatisPlugins/src" /> | |
23 | - <javaClientGenerator targetPackage="test.postgres" | |
24 | - targetProject="mybatisPlugins/src" type="XMLMAPPER" /> | |
25 | - | |
26 | - <table schema="public" tableName="AC%"> | |
27 | - <property name="ignoreQualifiersAtRuntime" value="true" /> | |
28 | - </table> | |
29 | - </context> | |
8 | + <plugin type="org.mybatis.generator.plugins.ToStringPlugin" /> | |
9 | + <commentGenerator type="ExtendCommentGenerator"> | |
10 | + <!-- | |
11 | + <property name="suppressAllComments" value="true" /> | |
12 | + <property name="suppressDate" value="true" /> | |
13 | + <property name="addRemarkComments" value="true" /> | |
14 | + --> | |
15 | + </commentGenerator> | |
16 | + <jdbcConnection driverClass="org.postgresql.Driver" | |
17 | + connectionURL="jdbc:postgresql://localhost/dvdrental" | |
18 | + userId="postgres" password="postgres" /> | |
19 | + <javaModelGenerator targetPackage="test.postgres" | |
20 | + targetProject="mybatisPlugins/src"> | |
21 | + <property name="trimStrings" value="true" /> | |
22 | + <property name="constructorBased" value="true" /> | |
23 | + </javaModelGenerator> | |
24 | + <sqlMapGenerator targetPackage="test.postgres" | |
25 | + targetProject="mybatisPlugins/src" /> | |
26 | + <javaClientGenerator targetPackage="test.postgres" | |
27 | + targetProject="mybatisPlugins/src" type="XMLMAPPER" /> | |
28 | + | |
29 | + <table schema="public" tableName="AC%"> | |
30 | + <property name="ignoreQualifiersAtRuntime" value="true" /> | |
31 | + </table> | |
32 | + </context> | |
30 | 33 | </generatorConfiguration> |
\ No newline at end of file |
@@ -0,0 +1,41 @@ | ||
1 | +import java.util.Properties; | |
2 | + | |
3 | +import org.mybatis.generator.api.CommentGenerator; | |
4 | +import org.mybatis.generator.api.IntrospectedColumn; | |
5 | +import org.mybatis.generator.api.IntrospectedTable; | |
6 | +import org.mybatis.generator.api.dom.java.Field; | |
7 | +import org.mybatis.generator.api.dom.java.Method; | |
8 | +import org.mybatis.generator.api.dom.java.TopLevelClass; | |
9 | + | |
10 | +public class ExtendCommentGenerator implements CommentGenerator { | |
11 | + | |
12 | + public void addConfigurationProperties(Properties properties) { | |
13 | + } | |
14 | + | |
15 | + public void addModelClassComment(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { | |
16 | + topLevelClass.addJavaDocLine("/**"); | |
17 | + topLevelClass.addJavaDocLine(" * " + introspectedTable.getRemarks()); | |
18 | + topLevelClass.addJavaDocLine(" */"); | |
19 | + } | |
20 | + | |
21 | + public void addFieldComment(Field field, IntrospectedTable introspectedTable, | |
22 | + IntrospectedColumn introspectedColumn) { | |
23 | + field.addJavaDocLine("/**"); | |
24 | + field.addJavaDocLine(" * " + introspectedColumn.getRemarks()); | |
25 | + field.addJavaDocLine(" */"); | |
26 | + } | |
27 | + | |
28 | + public void addGetterComment(Method method, IntrospectedTable introspectedTable, | |
29 | + IntrospectedColumn introspectedColumn) { | |
30 | + method.addJavaDocLine("/**"); | |
31 | + method.addJavaDocLine(" * @return " + introspectedColumn.getRemarks()); | |
32 | + method.addJavaDocLine(" */"); | |
33 | + } | |
34 | + | |
35 | + public void addSetterComment(Method method, IntrospectedTable introspectedTable, | |
36 | + IntrospectedColumn introspectedColumn) { | |
37 | + method.addJavaDocLine("/**"); | |
38 | + method.addJavaDocLine(" * @param " + introspectedColumn.getRemarks()); | |
39 | + method.addJavaDocLine(" */"); | |
40 | + } | |
41 | +} |