mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 09:38:26 +08:00
fix: 主键定义在父实体类,导致代码生成器报错,关闭:https://gitee.com/mybatis-flex/mybatis-flex/issues/IA92JK,https://gitee.com/mybatis-flex/mybatis-flex/issues/IB4LOU
This commit is contained in:
parent
be8ca9a572
commit
e234a818f8
@ -107,12 +107,16 @@ public class Table {
|
|||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认主键。
|
||||||
|
*/
|
||||||
|
private Column defaultPrimaryKey;
|
||||||
|
|
||||||
public Column getPrimaryKey() {
|
public Column getPrimaryKey() {
|
||||||
// 这里默认表中一定会有字段,就不做空判断了
|
if (defaultPrimaryKey == null) {
|
||||||
return columns.stream()
|
throw new NullPointerException("PrimaryKey can't be null");
|
||||||
.filter(Column::isPrimaryKey)
|
}
|
||||||
.findFirst()
|
return defaultPrimaryKey;
|
||||||
.orElseThrow(() -> new NullPointerException("PrimaryKey can't be null"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getPrimaryKeys() {
|
public Set<String> getPrimaryKeys() {
|
||||||
@ -176,6 +180,7 @@ public class Table {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> superColumns = null;
|
List<String> superColumns = null;
|
||||||
|
|
||||||
public void addColumn(Column column) {
|
public void addColumn(Column column) {
|
||||||
@ -193,15 +198,20 @@ public class Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (superColumns.contains(column.getProperty())){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 主键
|
// 主键
|
||||||
if (primaryKeys != null && primaryKeys.contains(column.getName())) {
|
if (primaryKeys != null && primaryKeys.contains(column.getName())) {
|
||||||
column.setPrimaryKey(true);
|
column.setPrimaryKey(true);
|
||||||
if (column.getAutoIncrement() == null && (column.getPropertyType().equals(Integer.class.getName()) || column.getPropertyType().equals(BigInteger.class.getName()))) {
|
if (column.getAutoIncrement() == null && (column.getPropertyType().equals(Integer.class.getName()) || column.getPropertyType().equals(BigInteger.class.getName()))) {
|
||||||
column.setAutoIncrement(true);
|
column.setAutoIncrement(true);
|
||||||
}
|
}
|
||||||
|
if (defaultPrimaryKey == null) {
|
||||||
|
defaultPrimaryKey = column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (superColumns.contains(column.getProperty())) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column.getAutoIncrement() == null) {
|
if (column.getAutoIncrement() == null) {
|
||||||
@ -386,6 +396,7 @@ public class Table {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建 kt 继承
|
* 构建 kt 继承
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -18,7 +18,6 @@ package com.mybatisflex.test;
|
|||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
import com.mybatisflex.core.MybatisFlexBootstrap;
|
import com.mybatisflex.core.MybatisFlexBootstrap;
|
||||||
import com.mybatisflex.core.datasource.DataSourceDecipher;
|
|
||||||
import com.mybatisflex.core.datasource.DataSourceManager;
|
import com.mybatisflex.core.datasource.DataSourceManager;
|
||||||
import com.mybatisflex.core.datasource.DataSourceProperty;
|
import com.mybatisflex.core.datasource.DataSourceProperty;
|
||||||
import com.mybatisflex.core.row.Db;
|
import com.mybatisflex.core.row.Db;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user