mybatis-generator構建表問題

在mysql中構建user等不同數據庫同名表時出現的問題,關鍵是兩點:

  1. catalog字段來加入數據庫名稱, 區分不同數據庫的同名表;
  2.  使用ignoreQualifiersAtRuntime來忽略前綴;

如果是需要返回自動產生的id,則需要加入generatedKey。           

    generatorConfig.xml中table段的代碼如下:

 <table catalog="wms" tableName="user">
        <!--默認爲false,如果設置爲true,在生成的SQL中,table名字不會加上catalog或schema-->
        <property name="ignoreQualifiersAtRuntime" value="true"/>
        <!-- 插入一條數據到數據庫之後,能從當前這個Entity中獲取到插入之後的Id -->
        <!-- <generatedKey column="ID" sqlStatement="Mysql" identity="true"/> -->
 </table>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章