Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mybatis generator "Column name pattern can not be NULL or empty"

I am using MyBatis Generator in eclipse. Here is the generatorConfig.xml file. When I right click and choose to "generate MyBatis artifacts", it show me the error message like "Column name pattern can not be NULL or empty".

<?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>
    <classPathEntry
        location="C:\Users\myplace\.m2\repository\mysql\mysql-connector-java\6.0.2\mysql-connector-java-6.0.2.jar" />
  <context id="context1">
  <plugin type="org.mybatis.generator.plugins.SerializablePlugin" />
        <plugin type="org.mybatis.generator.plugins.ToStringPlugin" />
  <jdbcConnection driverClass="com.mysql.jdbc.Driver"
            connectionURL="jdbc:mysql://localhost:3306/world?serverTimezone=EST"
            userId="root" password="root" />
    <javaModelGenerator targetPackage="com.example.ws.model" targetProject="com.example.ws" />
    <sqlMapGenerator targetPackage="com.example.ws.sql" targetProject="com.example.ws" />
   <javaClientGenerator targetPackage="com.example.ws.mapper" targetProject="com.example.ws" type="ANNOTATEDMAPPER" />
    <table schema="world" tableName="city">
      <columnOverride column="ID" property="id" javaType = "Integer" />
      <columnOverride column="Name" property="name" javaType = "String" />
      <columnOverride column="CuntryCode" property="cuntryCode" javaType = "String" />     
      <columnOverride column="District" property="district" javaType = "String" />
      <columnOverride column="Population" property="population" javaType = "BigDecimal" />
     </table>
  </context>
</generatorConfiguration>

Would you please help me with that? Thank you!

like image 365
TryMyBest Avatar asked Jun 28 '16 18:06

TryMyBest


2 Answers

This is a change in MySQL Connector from version 5.x to 6.x as commented here.

In order to get MyBatis work with 6.x you could append nullNamePatternMatchesAll=true to your JDBC string. You probably have to escape the & to &amp; in your XML.

like image 84
Jan Avatar answered Oct 19 '22 02:10

Jan


I have met the same error before.It might be caused by the db driver. After I change the mysql-connector from 6.0.3 down to 5.1.38,it never comes out again.

You can try to change your mysql-connector.

like image 5
商叶华 Avatar answered Oct 19 '22 00:10

商叶华