简体   繁体   中英

MyBatis Generator single resultMap

Im using MyBatis Generator to generate JavaBean and Mapper.xml.

But the Mapper.xml is different as I expected .

Mapper.xml contain two resultMap, BaseResultMap and ResultMapWithBLOBs .

I only want one resultMap contain all column.

Tough to know how you have your mybatis generator configuration set up, but the way to do this is through configuring the context's Model Type.

MBG provides an enum called ModelType which allows you to control how the Java Model classes (your beans) are generated. You want to use ModelType.FLAT in your context configuration to avoid any extra bean classes being created.

One option to avoid the creation of "WithBlobs" subclasses is to specify <columnOverride/> to use non-Blob jdbc types in your generator config for the Blob columns.

So, in the example of a TEXT column named "bar" in your table, you can specify VARCHAR instead:

    <table tableName='foo' domainObjectName='Foo'>
        <property name='useActualColumnNames' value='true' />
        <columnOverride column="bar" property="bar" jdbcType="VARCHAR" /> 
    </table>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM