Search code examples
mybatismybatis-generator

Table name not mapped to camel case by Mybatis Generator


I tried Mybatis Generator and it worked very well. However, even though the column names were mapped correctly to camel case, the file names (Mapper.xml, Client and Model) didn't follow camel case.

So, for example, table TIPO_SERVICO was mapped to Tiposervico/TiposervicoMapper instead of TipoServico/TipoServicoMapper.

I checked Mybatis Generator docs and didn't find a property related to table name case.

P.s. My DB is Oracle.

My generatorConfig.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC
        "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<generatorConfiguration>
    <context id="context" targetRuntime="MyBatis3Simple">
        <commentGenerator>
            <property name="suppressAllComments" value="true"/>
        </commentGenerator>

        <jdbcConnection userId="[USER]" password="[PASSWORD]" driverClass="oracle.jdbc.OracleDriver" connectionURL="jdbc:oracle:thin:@[IP]:1521:[ENV]">
            <property name="remarksReporting" value="true"/>
        </jdbcConnection>

        <javaTypeResolver>
            <property name="forceBigDecimals" value="false"/>
        </javaTypeResolver>

        <javaModelGenerator targetPackage="com.model" targetProject="src/main/java">
            <property name="enableSubPackages" value="false"/>
            <property name="trimStrings" value="true"/>
        </javaModelGenerator>

        <sqlMapGenerator targetPackage="com.mapper" targetProject="src/main/resources/META-INF">
            <property name="enableSubPackages" value="false"/>
        </sqlMapGenerator>

        <javaClientGenerator targetPackage="com.mapper" type="XMLMAPPER" targetProject="src/main/java">
            <property name="enableSubPackages" value="false"/>
        </javaClientGenerator>

        <table schema="patr" tableName="%" enableCountByExample="true" enableDeleteByExample="false"
               enableSelectByExample="true" enableUpdateByExample="false" >
            <domainObjectRenamingRule searchString="^Scm" replaceString="" />
        </table>
    </context>
</generatorConfiguration>

Solution

  • Camel case naming worked again after commenting the domainObjectRenamingRule.