From 1570eaf6d8d6f598a64212941faa167f0dcaeb17 Mon Sep 17 00:00:00 2001 From: lidongy <1879087903@qq.com> Date: Wed, 7 Dec 2022 14:45:55 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-85191=E3=80=90=E5=9B=BD=E4=BA=A7?= =?UTF-8?q?=E5=8C=96=E3=80=91=E9=85=8D=E7=BD=AE=E5=BA=93=E9=80=82=E9=85=8D?= =?UTF-8?q?GoldenDB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../third/org/hibernate/dialect/Dialect.java | 18 ++++++++++++++++++ .../fr/third/org/hibernate/mapping/Column.java | 2 +- .../org/hibernate/mapping/PrimaryKey.java | 6 +++++- .../schema/internal/StandardTableExporter.java | 2 ++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/Dialect.java b/fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/Dialect.java index c86f19177..61533304f 100644 --- a/fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/Dialect.java +++ b/fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/Dialect.java @@ -2806,4 +2806,22 @@ public abstract class Dialect implements ConversionContext { return buf.append(')').toString(); } + /** + * 获取建表时分发策略字符串 + * + * @param columnList 主键列集合 + * @return String + */ + public String sqlDistributeString(List columnList) { + return ""; + } + + /** + * 是否强制添加引用符号 + * + * @return 是/否 + */ + public boolean forceQuote() { + return false; + } } diff --git a/fine-hibernate/src/main/java/com/fr/third/org/hibernate/mapping/Column.java b/fine-hibernate/src/main/java/com/fr/third/org/hibernate/mapping/Column.java index 2d155867b..6cf5b7bd7 100644 --- a/fine-hibernate/src/main/java/com/fr/third/org/hibernate/mapping/Column.java +++ b/fine-hibernate/src/main/java/com/fr/third/org/hibernate/mapping/Column.java @@ -96,7 +96,7 @@ public class Column implements Selectable, Serializable, Cloneable { } public String getQuotedName(Dialect d) { - return quoted ? + return quoted || d.forceQuote() ? d.openQuote() + name + d.closeQuote() : name; } diff --git a/fine-hibernate/src/main/java/com/fr/third/org/hibernate/mapping/PrimaryKey.java b/fine-hibernate/src/main/java/com/fr/third/org/hibernate/mapping/PrimaryKey.java index 48f13c807..085505e70 100644 --- a/fine-hibernate/src/main/java/com/fr/third/org/hibernate/mapping/PrimaryKey.java +++ b/fine-hibernate/src/main/java/com/fr/third/org/hibernate/mapping/PrimaryKey.java @@ -74,7 +74,11 @@ public class PrimaryKey extends Constraint { } return buf.append(')').toString(); } - + + public String sqlDistributeString(Dialect dialect) { + return dialect.sqlDistributeString(getColumns()); + } + public String generatedConstraintNamePrefix() { return "PK_"; } diff --git a/fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/StandardTableExporter.java b/fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/StandardTableExporter.java index b52b97a8f..713717420 100644 --- a/fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/StandardTableExporter.java +++ b/fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/StandardTableExporter.java @@ -154,6 +154,8 @@ public class StandardTableExporter implements Exporter { applyInitCommands( table, sqlStrings ); + buf.append(table.getPrimaryKey().sqlDistributeString(dialect)); + return sqlStrings.toArray( new String[ sqlStrings.size() ] ); }