mybatis / generator

A code generator for MyBatis.
http://www.mybatis.org/generator/
5.28k stars 2.52k forks source link

Suggestions on DynamicSqlSupport #1225

Closed mailingfeng closed 3 weeks ago

mailingfeng commented 2 months ago

Version: 1.4.2

Suggestion

table name as static variable,which can be used in other scenarios

// Now
public final class CorpDynamicSqlSupport {

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    public static final class Corp extends AliasableSqlTable<Corp> {
        public final SqlColumn<String> corpId = column("corp_id", JDBCType.VARCHAR);

        public ScheduleCorpConfigItem() {
            super("corp", ScheduleCorpConfigItem::new);
        }
   }
}

// Suggestion Change
public final class CorpDynamicSqlSupport {
    // !!!
    public static final String TABLE_NAME = "corp";

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    public static final class Corp extends AliasableSqlTable<Corp> {
        public final SqlColumn<String> corpId = column("corp_id", JDBCType.VARCHAR);

        public ScheduleCorpConfigItem() {
            super(TABLE_NAME, ScheduleCorpConfigItem::new);
        }
   }
}
jeffgbutler commented 2 months ago

You could add the TABLE_NAME field with a plugin if it would be useful to you.