MyBatis Generator配置文件--指定生成实体类的属性名

table标签下的设置属性useActualColumnNames用于指定生成实体类时是否使用实际的列名作为实体类的属性名,取值true或false。
true:MyBatis Generator会使用数据库中实际的字段名字作为生成的实体类的属性名。

false:这是默认值。如果设置为false,则MyBatis Generator会将数据库中实际的字段名字转换为Camel Case风格作为生成的实体类的属性名。

如果明确的使用columnOverride元素指定了字段对应的实体的属性名,那么useActualColumnNames会被忽略。
例:

<table tableName="v_user_detail" domainObjectName="VUserDetail"
       enableCountByExample="false" enableUpdateByExample="false"
       enableDeleteByExample="false" enableSelectByExample="false"
       selectByExampleQueryId="false" enableInsert="false"
       enableSelectByPrimaryKey="true" selectByPrimaryKeyQueryId="true">
      <property name="useActualColumnNames" value="true"/>
</table>

如果需要自行指定数据库与实体类的对应字段,可以使用 columnOverride
例:

<table tableName="v_user_detail" domainObjectName="VUserDetail"
       enableCountByExample="false" enableUpdateByExample="false"
       enableDeleteByExample="false" enableSelectByExample="false"
       selectByExampleQueryId="false" enableInsert="false"
       enableSelectByPrimaryKey="true" selectByPrimaryKeyQueryId="true">
       <columnOverride column="userid" property="userId" javaType="java.lang.Integer" jdbcType="INTEGER" />
       <columnOverride column="createtime" property="createTime"/>
       <columnOverride column="updatetime" property="updateTime"/>
</table>

columnOverride也可以针对字段类型为text等会默认产生XXXXWithBlobs的方法问题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值