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的方法问题