Based on the revision and source code analysis of mybatis-generator-core 1.3.5, mybatisgeneratorcore

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.