首先感谢波总百忙之中指点:
第一步:将源码中model_template拷贝一份放到自己项目里
第二步:将修改后的模板set到generator中
附上修改后模板代码
package #(baseModelPackageName); import com.jfinal.plugin.activerecord.Model; import com.jfinal.plugin.activerecord.IBean; import com.jfinal.plugin.activerecord.Table; /** * Generated by JFinal, do not modify this file. */ #if (generateChainSetter) @SuppressWarnings({"serial", "unchecked"}) #else @SuppressWarnings("serial") #end public abstract class #(tableMeta.baseModelName)<M extends #(tableMeta.baseModelName)<M>> extends Model<M> implements IBean { public static final String tableName = "#(tableMeta.name)"; #set(b = generateChainSetter) #for(cm : tableMeta.columnMetas) #set(argName = javaKeyword.contains(cm.attrName) ? '_' + cm.attrName : cm.attrName) public #(b ? 'M' : 'void') set#(firstCharToUpperCase(cm.attrName))(#(cm.javaType) #(argName)) { set("#(cm.name)", #(argName)); #if (b) return (M)this; #end } #set(getterOfModel = getterTypeMap.get(cm.javaType)) #if (isBlank(getterOfModel)) #set(getterOfModel = 'get') #end public #(cm.javaType) get#(firstCharToUpperCase(cm.attrName))() { return #(getterOfModel)("#(cm.name)"); } #end }
就加了第17行那一行代码,其它没有改变
接下来可以在项目中任意地方model.tableName,就是该model对应数据库中的表名了
感谢你的分享