@Override
    public void tableConfiguration(IntrospectedTable introspectedTable) {
        try {
            TableConfiguration tableConfiguration = introspectedTable.getTableConfiguration();
            FullyQualifiedTable fullyQualifiedTable = introspectedTable.getFullyQualifiedTable();

            String tableReplaceDisable = tableConfiguration.getProperty(PRO_TABLE_REPLACE_DISABLE);
            this.tableReplaceDisable = tableReplaceDisable == null ? false : StringUtility.isTrue(tableReplaceDisable);
            String columnReplaceDisable = tableConfiguration.getProperty(PRO_COLUMN_REPLACE_DISABLE);
            this.columnReplaceDisable = columnReplaceDisable == null ? false : StringUtility.isTrue(columnReplaceDisable);

            String javaClientInterfacePackage = (String) BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateJavaClientInterfacePackage");
            String sqlMapPackage = (String) BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateSqlMapPackage");
            String javaModelPackage = (String) BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateJavaModelPackage");
            // --------------------- table 重命名 ----------------------------
            if (tableConfiguration.getDomainObjectRenamingRule() == null
                    && this.tableSearchString != null && !this.tableReplaceDisable) {
                DomainObjectRenamingRule rule = new DomainObjectRenamingRule();
                rule.setSearchString(this.tableSearchString);
                rule.setReplaceString(this.tableReplaceString);
                tableConfiguration.setDomainObjectRenamingRule(rule);
                BeanUtils.setProperty(introspectedTable.getFullyQualifiedTable(), "domainObjectRenamingRule", rule);

                // 重新初始化一下属性
                BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateJavaClientAttributes");
                BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateModelAttributes");
                BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateXmlAttributes");
            }
            // TODO 官方bug临时修复
            if (tableConfiguration.getDomainObjectRenamingRule() != null) {
                String domainObjectName = fullyQualifiedTable.getDomainObjectName();
                // 首字母大写
                BeanUtils.setProperty(fullyQualifiedTable, "domainObjectName", getCamelCaseString(domainObjectName, true));

                // 重新初始化一下属性
                BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateJavaClientAttributes");
                BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateModelAttributes");
                BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateXmlAttributes");
            }
            // --------------------- column 重命名 ---------------------------
            if (tableConfiguration.getColumnRenamingRule() == null
                    && this.columnSearchString != null && !this.columnReplaceDisable) {
                ColumnRenamingRule rule = new ColumnRenamingRule();
                rule.setSearchString(this.columnSearchString);
                rule.setReplaceString(this.columnReplaceString);
                tableConfiguration.setColumnRenamingRule(rule);

                // introspectedTable 使用到的所有column过滤并替换
                this.renameColumns(introspectedTable.getAllColumns(), rule, tableConfiguration);
            }

            // ---------------------- 后缀修正 -------------------------------
            // 1. client
            if (this.clientSuffix != null) {
                // mapper
                StringBuilder sb = new StringBuilder();
                sb.append(javaClientInterfacePackage);
                sb.append('.');
                if (stringHasValue(tableConfiguration.getMapperName())) {
                    sb.append(tableConfiguration.getMapperName());
                } else {
                    if (stringHasValue(fullyQualifiedTable.getDomainObjectSubPackage())) {
                        sb.append(fullyQualifiedTable.getDomainObjectSubPackage());
                        sb.append('.');
                    }
                    sb.append(fullyQualifiedTable.getDomainObjectName());
                    sb.append(this.clientSuffix);
                }
                introspectedTable.setMyBatis3JavaMapperType(sb.toString());
                // xml mapper namespace
                sb.setLength(0);
                sb.append(sqlMapPackage);
                sb.append('.');
                if (stringHasValue(tableConfiguration.getMapperName())) {
                    sb.append(tableConfiguration.getMapperName());
                } else {
                    sb.append(fullyQualifiedTable.getDomainObjectName());
                    sb.append(this.clientSuffix);
                }
                introspectedTable.setMyBatis3FallbackSqlMapNamespace(sb.toString());
                // xml file
                sb.setLength(0);
                sb.append(fullyQualifiedTable.getDomainObjectName());
                sb.append(this.clientSuffix);
                sb.append(".xml");

                introspectedTable.setMyBatis3XmlMapperFileName(sb.toString());
            }
            // 2. example
            if (this.exampleSuffix != null) {
                StringBuilder sb = new StringBuilder();
                sb.append(javaModelPackage);
                sb.append('.');
                sb.append(fullyQualifiedTable.getDomainObjectName());
                sb.append(this.exampleSuffix);
                introspectedTable.setExampleType(sb.toString());
            }
            // 3. model
            if (this.modelSuffix != null) {
                StringBuilder sb = new StringBuilder();
                sb.append(javaModelPackage);
                sb.append('.');
                sb.append(fullyQualifiedTable.getDomainObjectName());
                sb.append("Key");
                sb.append(this.modelSuffix);
                introspectedTable.setPrimaryKeyType(sb.toString());

                sb.setLength(0);
                sb.append(javaModelPackage);
                sb.append('.');
                sb.append(fullyQualifiedTable.getDomainObjectName());
                sb.append(this.modelSuffix);
                introspectedTable.setBaseRecordType(sb.toString());

                sb.setLength(0);
                sb.append(javaModelPackage);
                sb.append('.');
                sb.append(fullyQualifiedTable.getDomainObjectName());
                sb.append("WithBLOBs");
                sb.append(this.modelSuffix);
                introspectedTable.setRecordWithBLOBsType(sb.toString());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
@Override
    public void tableConfiguration(IntrospectedTable introspectedTable) {
        try {
            TableConfiguration tableConfiguration = introspectedTable.getTableConfiguration();
            FullyQualifiedTable fullyQualifiedTable = introspectedTable.getFullyQualifiedTable();

            String tableReplaceDisable = tableConfiguration.getProperty(PRO_TABLE_REPLACE_DISABLE);
            this.tableReplaceDisable = tableReplaceDisable == null ? false : StringUtility.isTrue(tableReplaceDisable);
            String columnReplaceDisable = tableConfiguration.getProperty(PRO_COLUMN_REPLACE_DISABLE);
            this.columnReplaceDisable = columnReplaceDisable == null ? false : StringUtility.isTrue(columnReplaceDisable);

            String javaClientInterfacePackage = (String) BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateJavaClientInterfacePackage");
            String sqlMapPackage = (String) BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateSqlMapPackage");
            String javaModelPackage = (String) BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateJavaModelPackage");
            
            if (tableConfiguration.getDomainObjectRenamingRule() == null
                    && this.tableSearchString != null && !this.tableReplaceDisable) {
                DomainObjectRenamingRule rule = new DomainObjectRenamingRule();
                rule.setSearchString(this.tableSearchString);
                rule.setReplaceString(this.tableReplaceString);
                tableConfiguration.setDomainObjectRenamingRule(rule);
                BeanUtils.setProperty(introspectedTable.getFullyQualifiedTable(), "domainObjectRenamingRule", rule);

                
                BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateJavaClientAttributes");
                BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateModelAttributes");
                BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateXmlAttributes");
            }
            
            if (tableConfiguration.getDomainObjectRenamingRule() != null) {
                String domainObjectName = fullyQualifiedTable.getDomainObjectName();
                
                BeanUtils.setProperty(fullyQualifiedTable, "domainObjectName", getCamelCaseString(domainObjectName, true));

                
                BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateJavaClientAttributes");
                BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateModelAttributes");
                BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateXmlAttributes");
            }
            
            if (tableConfiguration.getColumnRenamingRule() == null
                    && this.columnSearchString != null && !this.columnReplaceDisable) {
                ColumnRenamingRule rule = new ColumnRenamingRule();
                rule.setSearchString(this.columnSearchString);
                rule.setReplaceString(this.columnReplaceString);
                tableConfiguration.setColumnRenamingRule(rule);

                
                this.renameColumns(introspectedTable.getAllColumns(), rule, tableConfiguration);
            }

            
            
            if (this.clientSuffix != null) {
                
                StringBuilder sb = new StringBuilder();
                sb.append(javaClientInterfacePackage);
                sb.append('.');
                if (stringHasValue(tableConfiguration.getMapperName())) {
                    sb.append(tableConfiguration.getMapperName());
                } else {
                    if (stringHasValue(fullyQualifiedTable.getDomainObjectSubPackage())) {
                        sb.append(fullyQualifiedTable.getDomainObjectSubPackage());
                        sb.append('.');
                    }
                    sb.append(fullyQualifiedTable.getDomainObjectName());
                    sb.append(this.clientSuffix);
                }
                introspectedTable.setMyBatis3JavaMapperType(sb.toString());
                
                sb.setLength(0);
                sb.append(sqlMapPackage);
                sb.append('.');
                if (stringHasValue(tableConfiguration.getMapperName())) {
                    sb.append(tableConfiguration.getMapperName());
                } else {
                    sb.append(fullyQualifiedTable.getDomainObjectName());
                    sb.append(this.clientSuffix);
                }
                introspectedTable.setMyBatis3FallbackSqlMapNamespace(sb.toString());
                
                sb.setLength(0);
                sb.append(fullyQualifiedTable.getDomainObjectName());
                sb.append(this.clientSuffix);
                sb.append(".xml");

                introspectedTable.setMyBatis3XmlMapperFileName(sb.toString());
            }
            
            if (this.exampleSuffix != null) {
                StringBuilder sb = new StringBuilder();
                sb.append(javaModelPackage);
                sb.append('.');
                sb.append(fullyQualifiedTable.getDomainObjectName());
                sb.append(this.exampleSuffix);
                introspectedTable.setExampleType(sb.toString());
            }
            
            if (this.modelSuffix != null) {
                StringBuilder sb = new StringBuilder();
                sb.append(javaModelPackage);
                sb.append('.');
                sb.append(fullyQualifiedTable.getDomainObjectName());
                sb.append("Key");
                sb.append(this.modelSuffix);
                introspectedTable.setPrimaryKeyType(sb.toString());

                sb.setLength(0);
                sb.append(javaModelPackage);
                sb.append('.');
                sb.append(fullyQualifiedTable.getDomainObjectName());
                sb.append(this.modelSuffix);
                introspectedTable.setBaseRecordType(sb.toString());

                sb.setLength(0);
                sb.append(javaModelPackage);
                sb.append('.');
                sb.append(fullyQualifiedTable.getDomainObjectName());
                sb.append("WithBLOBs");
                sb.append(this.modelSuffix);
                introspectedTable.setRecordWithBLOBsType(sb.toString());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
@ Override public void tableConfiguration ( IntrospectedTable introspectedTable ) { try { TableConfiguration tableConfiguration = introspectedTable . getTableConfiguration ( ) ; FullyQualifiedTable fullyQualifiedTable = introspectedTable . getFullyQualifiedTable ( ) ; String tableReplaceDisable = tableConfiguration . getProperty ( PRO_TABLE_REPLACE_DISABLE ) ; this . tableReplaceDisable = tableReplaceDisable == null ? false : StringUtility . isTrue ( tableReplaceDisable ) ; String columnReplaceDisable = tableConfiguration . getProperty ( PRO_COLUMN_REPLACE_DISABLE ) ; this . columnReplaceDisable = columnReplaceDisable == null ? false : StringUtility . isTrue ( columnReplaceDisable ) ; String javaClientInterfacePackage = ( String ) BeanUtils . invoke ( introspectedTable , IntrospectedTable . class , "calculateJavaClientInterfacePackage" ) ; String sqlMapPackage = ( String ) BeanUtils . invoke ( introspectedTable , IntrospectedTable . class , "calculateSqlMapPackage" ) ; String javaModelPackage = ( String ) BeanUtils . invoke ( introspectedTable , IntrospectedTable . class , "calculateJavaModelPackage" ) ; // --------------------- table 重命名 ---------------------------- if ( tableConfiguration . getDomainObjectRenamingRule ( ) == null && this . tableSearchString != null && ! this . tableReplaceDisable ) { DomainObjectRenamingRule rule = new DomainObjectRenamingRule ( ) ; rule . setSearchString ( this . tableSearchString ) ; rule . setReplaceString ( this . tableReplaceString ) ; tableConfiguration . setDomainObjectRenamingRule ( rule ) ; BeanUtils . setProperty ( introspectedTable . getFullyQualifiedTable ( ) , "domainObjectRenamingRule" , rule ) ; // 重新初始化一下属性 BeanUtils . invoke ( introspectedTable , IntrospectedTable . class , "calculateJavaClientAttributes" ) ; BeanUtils . invoke ( introspectedTable , IntrospectedTable . class , "calculateModelAttributes" ) ; BeanUtils . invoke ( introspectedTable , IntrospectedTable . class , "calculateXmlAttributes" ) ; } // TODO 官方bug临时修复 if ( tableConfiguration . getDomainObjectRenamingRule ( ) != null ) { String domainObjectName = fullyQualifiedTable . getDomainObjectName ( ) ; // 首字母大写 BeanUtils . setProperty ( fullyQualifiedTable , "domainObjectName" , getCamelCaseString ( domainObjectName , true ) ) ; // 重新初始化一下属性 BeanUtils . invoke ( introspectedTable , IntrospectedTable . class , "calculateJavaClientAttributes" ) ; BeanUtils . invoke ( introspectedTable , IntrospectedTable . class , "calculateModelAttributes" ) ; BeanUtils . invoke ( introspectedTable , IntrospectedTable . class , "calculateXmlAttributes" ) ; } // --------------------- column 重命名 --------------------------- if ( tableConfiguration . getColumnRenamingRule ( ) == null && this . columnSearchString != null && ! this . columnReplaceDisable ) { ColumnRenamingRule rule = new ColumnRenamingRule ( ) ; rule . setSearchString ( this . columnSearchString ) ; rule . setReplaceString ( this . columnReplaceString ) ; tableConfiguration . setColumnRenamingRule ( rule ) ; // introspectedTable 使用到的所有column过滤并替换 this . renameColumns ( introspectedTable . getAllColumns ( ) , rule , tableConfiguration ) ; } // ---------------------- 后缀修正 ------------------------------- // 1. client if ( this . clientSuffix != null ) { // mapper StringBuilder sb = new StringBuilder ( ) ; sb . append ( javaClientInterfacePackage ) ; sb . append ( ' ' ) ; if ( stringHasValue ( tableConfiguration . getMapperName ( ) ) ) { sb . append ( tableConfiguration . getMapperName ( ) ) ; } else { if ( stringHasValue ( fullyQualifiedTable . getDomainObjectSubPackage ( ) ) ) { sb . append ( fullyQualifiedTable . getDomainObjectSubPackage ( ) ) ; sb . append ( ' ' ) ; } sb . append ( fullyQualifiedTable . getDomainObjectName ( ) ) ; sb . append ( this . clientSuffix ) ; } introspectedTable . setMyBatis3JavaMapperType ( sb . toString ( ) ) ; // xml mapper namespace sb . setLength ( 0 ) ; sb . append ( sqlMapPackage ) ; sb . append ( ' ' ) ; if ( stringHasValue ( tableConfiguration . getMapperName ( ) ) ) { sb . append ( tableConfiguration . getMapperName ( ) ) ; } else { sb . append ( fullyQualifiedTable . getDomainObjectName ( ) ) ; sb . append ( this . clientSuffix ) ; } introspectedTable . setMyBatis3FallbackSqlMapNamespace ( sb . toString ( ) ) ; // xml file sb . setLength ( 0 ) ; sb . append ( fullyQualifiedTable . getDomainObjectName ( ) ) ; sb . append ( this . clientSuffix ) ; sb . append ( ".xml" ) ; introspectedTable . setMyBatis3XmlMapperFileName ( sb . toString ( ) ) ; } // 2. example if ( this . exampleSuffix != null ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( javaModelPackage ) ; sb . append ( ' ' ) ; sb . append ( fullyQualifiedTable . getDomainObjectName ( ) ) ; sb . append ( this . exampleSuffix ) ; introspectedTable . setExampleType ( sb . toString ( ) ) ; } // 3. model if ( this . modelSuffix != null ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( javaModelPackage ) ; sb . append ( ' ' ) ; sb . append ( fullyQualifiedTable . getDomainObjectName ( ) ) ; sb . append ( "Key" ) ; sb . append ( this . modelSuffix ) ; introspectedTable . setPrimaryKeyType ( sb . toString ( ) ) ; sb . setLength ( 0 ) ; sb . append ( javaModelPackage ) ; sb . append ( ' ' ) ; sb . append ( fullyQualifiedTable . getDomainObjectName ( ) ) ; sb . append ( this . modelSuffix ) ; introspectedTable . setBaseRecordType ( sb . toString ( ) ) ; sb . setLength ( 0 ) ; sb . append ( javaModelPackage ) ; sb . append ( ' ' ) ; sb . append ( fullyQualifiedTable . getDomainObjectName ( ) ) ; sb . append ( "WithBLOBs" ) ; sb . append ( this . modelSuffix ) ; introspectedTable . setRecordWithBLOBsType ( sb . toString ( ) ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } }
表配置
@param introspectedTable
表配置