Based on the revision and source code analysis of mybatis-generator-core 1.3.5, mybatisgeneratorcore
Project Description
Mybatis-generator is used to generate code files such as entity classes based on database tables and fields. During the National Day, I analyzed the mybatis-generator-core source code and wrote quite detailed Chinese comments. Let's take a look. Currently, I have modified the 1.3.5 version.
Source code profiling
1. Analyze the source code of org. mybatis. generator. plugins. ToStringPlugin.
2. Analyze org. mybatis. generator. plugins. MapperConfigPlugin source code
3. Analyze org. mybatis. generator. api. ShellRunner source code, Main Entry
3. Analyze org. mybatis. generator. config. xml. ConfigurationParser source code and configure the parser for parsing the generatorConfig. xml configuration file.
4. Analyze the source code of org. mybatis. generator. config. Context and encapsulate the element content.
Modify source code description (functions not available in the original version)
1. add the remarks of the data table: add the remark field to the FullyQualifiedTable class, and add the remark field in org. mybatis. generator. internal. db. databaseIntrospector class calculateIntrospectedTables method, add a piece of code to get database remarks
1 // set the remarks of the Database Table 2 // start 3 Statement stmt = this. databaseMetaData. getConnection (). createStatement (); 4 ResultSet rs = stmt.exe cuteQuery (5 new StringBuilder () 6. append ("show table status like '") 7. append (atn. getTableName () 8. append ("'") 9. toString (); 10 while (rs. next () 11 table. setRemark (rs. getString ("COMMENT"); 12 closeResultSet (rs); 13 stmt. close (); 14 // end
2. Add annotation methods for non-model class Example. Method Name: addExampleClassComment (TopLevelClass topLevelClass)
3. refactoring part org. mybatis. generator. codegen. mybatis3.IntrospectedTableMyBatis3Impl getGeneratedJavaFiles Method
4. Add detailed Chinese comments. The entry package function is in org. mybatis. generator. api. ShellRunner.
5. The Generated Chinese comments can be modified in the DefaultCommentGenerator class.
Source Code address: https://github.com/orange1438/mybatis-generator-core-chinese-annotation-1.3.5