From c548571fbd1c044e56c9ad0c7f9bd0e2295f43de Mon Sep 17 00:00:00 2001 From: Elijah Date: Wed, 23 Jun 2021 16:57:04 +0800 Subject: [PATCH] =?UTF-8?q?DEC-19255=20fix=20=E5=AF=B9=E4=B9=8B=E5=89=8D?= =?UTF-8?q?=E4=B8=BB=E9=94=AE=E4=B8=A2=E5=A4=B1=E7=9A=84=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E8=A1=A8=E5=81=9Anpe=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tool/schema/internal/AbstractSchemaMigrator.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java b/fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java index d3e452571..bbe67279e 100644 --- a/fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java +++ b/fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java @@ -362,7 +362,9 @@ public abstract class AbstractSchemaMigrator implements SchemaMigrator { Set identifiers = getUniqueKeyIdentifiers(table); if (tableInfo != null) { for (IndexInformation indexInfo : tableInfo.getIndexes()) { - if (!indexInfo.isUnique() || indexInfo.getIndexIdentifier().equals(tableInfo.getPrimaryKey().getPrimaryKeyIdentifier())) { + PrimaryKeyInformation primaryKey = tableInfo.getPrimaryKey(); + //主键不存在时npe处理 + if (!indexInfo.isUnique() || (primaryKey != null && indexInfo.getIndexIdentifier().equals(primaryKey.getPrimaryKeyIdentifier()))) { continue; } //如果旧的唯一键已经不存在, 则删除