baomidou / mybatis-plus-doc

MyBatis-Plus Official Documentation

Home Page:https://baomidou.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

H2Query代码生成器失败

yame2009 opened this issue · comments

PK_QUERY_SQL = "select * from INFORMATION_SCHEMA.INDEXES WHERE TABLE_NAME = '%s'" ,查找"PRIMARY_KEY"失败。H2数据库没有COLUMN_NAME字段。
“select * from INFORMATION_SCHEMA.INDEXES” 查询内容如下:
index_catalog index_schema index_name table_catalog table_schema table_name index_type_name is_generated remarks index_class
h2 public PRIMARY_KEY_14 h2 public user_demo PRIMARY KEY TRUE null org.h2.mvstore.db.MVSecondaryIndex

上述sql查询失败后,导致下面代码执行异常com.baomidou.mybatisplus.generator.IDatabaseQuery.DefaultDatabaseQuery#convertTableFields
具体实现代码:
if (DbType.H2 == dbType) {
dbQuery.query(String.format(H2Query.PK_QUERY_SQL, tableName), result -> {
String primaryKey = result.getStringResult(dbQuery.fieldKey()); -- 这一行报错
if (Boolean.parseBoolean(primaryKey)) {
h2PkColumns.add(result.getStringResult(dbQuery.fieldName()));
}
});
}