Mybatis生成器配置设置tableName区分大小写

时间:2018-03-14 11:02:22

标签: mybatis spring-mybatis mybatis-generator

这是我的xml配置:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
    <context id="DB2SAMPLE" defaultModelType="flat" targetRuntime="MyBatis3">

        <plugin type="org.mybatis.generator.plugins.RenameExampleClassPlugin">
            <property name="searchString" value="Example$"/>
            <property name="replaceString" value="Criteria"/>
        </plugin>

        <plugin type="org.mybatis.generator.plugins.CaseInsensitiveLikePlugin" />

        <plugin type="org.mybatis.generator.plugins.RowBoundsPlugin" />

        <commentGenerator>
            <property name="suppressAllComments" value="true" />             
        </commentGenerator>

        <jdbcConnection driverClass="com.ibm.db2.jcc.DB2Driver" connectionURL="jdbc:db2://LOCALHOST:50000/mydb" userId="username" password="password">
        </jdbcConnection>

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

        <sqlMapGenerator targetPackage="foo.package" targetProject="src/main/resources">
            <property name="enableSubPackages" value="true" />
        </sqlMapGenerator>

        <javaClientGenerator type="XMLMAPPER" targetPackage="foo.package" targetProject="src/main/java">
            <property name="enableSubPackages" value="true" />
        </javaClientGenerator>

        <table schema="SCHEMA" tableName="MyTable" alias="MYTABLE" domainObjectName="MYTABLE"/>

    </context>
</generatorConfiguration>

问题在于找不到表MyTable,因为它搜索MYTABLE

如何设置MyBatis生成器以搜索区分大小写的名称MyTable

感谢。

1 个答案:

答案 0 :(得分:0)

来自https://www.codeday.top/2016/12/22/6853.html

1, If schema,catalog or tablename There are spaces in , So what format is set , On the exact use of the specified format to query ;
2, otherwise , If the database identifier uses uppercase , that MBG Automatically turn table name into uppercase search ;
3, otherwise , If the database identifier uses lowercase , that MBG Automatically turn table name to lowercase search ;
4, otherwise , Query using the specified case format ;
 Additional , If the table is created , Using "" Specify database object size , Even if the database identifier is used , In this case a table name is created using a given case size ;
 At this time , Please set delimitIdentifiers="true" Case preserving format ;