From 352eb2fae16ec614d50da59fd52514b2a20186a1 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Thu, 12 Aug 2021 18:47:51 -0700 Subject: [PATCH] HHH-14744 : HHH-14744 : Refactor contextual information for SchemaManagementTool to be more easily extended by Hibernate Reactive Move methods from PostgreSQL10Dialect into PostgreSQL81Dialect; remove @GeneratedValue from SchemaUpdateTest --- .../org/hibernate/dialect/PostgreSQL10Dialect.java | 12 ------------ .../org/hibernate/dialect/PostgreSQL81Dialect.java | 13 +++++++++++++ .../test/schemaupdate/SchemaUpdateTest.java | 7 ------- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL10Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL10Dialect.java index 37dfba3f92..336bdd41d3 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL10Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL10Dialect.java @@ -41,20 +41,8 @@ public class PostgreSQL10Dialect extends PostgreSQL95Dialect { tableTypesList.add( "PARTITIONED TABLE" ); } - @Override - public NameQualifierSupport getNameQualifierSupport() { - // This method is overridden so the correct value will be returned when - // DatabaseMetaData is not available. - return NameQualifierSupport.SCHEMA; - } - @Override public SequenceInformationExtractor getSequenceInformationExtractor() { return SequenceInformationExtractorPostgresSQLDatabaseImpl.INSTANCE; } - - @Override - public String getCurrentSchemaCommand() { - return "select current_schema from sys.dummy"; - } } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java index 95ea786bf3..aee33307bc 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java @@ -32,6 +32,7 @@ import org.hibernate.dialect.pagination.LimitHelper; import org.hibernate.engine.jdbc.env.spi.IdentifierCaseStrategy; import org.hibernate.engine.jdbc.env.spi.IdentifierHelper; import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder; +import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport; import org.hibernate.engine.spi.RowSelection; import org.hibernate.exception.LockAcquisitionException; import org.hibernate.exception.spi.SQLExceptionConversionDelegate; @@ -215,6 +216,18 @@ public class PostgreSQL81Dialect extends Dialect { return descriptor; } + @Override + public NameQualifierSupport getNameQualifierSupport() { + // This method is overridden so the correct value will be returned when + // DatabaseMetaData is not available. + return NameQualifierSupport.SCHEMA; + } + + @Override + public String getCurrentSchemaCommand() { + return "select current_schema()"; + } + @Override public String getAddColumnString() { return "add column"; diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaUpdateTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaUpdateTest.java index e0cb4d6756..8d3c544767 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaUpdateTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaUpdateTest.java @@ -21,7 +21,6 @@ import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.ForeignKey; -import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.Inheritance; @@ -164,7 +163,6 @@ public class SchemaUpdateTest { @Table(name = "`testentity`") public static class LowercaseTableNameEntity { @Id - @GeneratedValue long id; String field1; @@ -175,7 +173,6 @@ public class SchemaUpdateTest { @Entity(name = "TestEntity1") public static class TestEntity { @Id - @GeneratedValue @Column(name = "`Id`") long id; String field1; @@ -195,7 +192,6 @@ public class SchemaUpdateTest { @Table(name = "`TESTENTITY`") public static class UppercaseTableNameEntity { @Id - @GeneratedValue long id; String field1; @@ -211,7 +207,6 @@ public class SchemaUpdateTest { @Table(name = "`TESTentity`", indexes = {@Index(name = "index1", columnList = "`FieLd1`"), @Index(name = "Index2", columnList = "`FIELD_2`")}) public static class MixedCaseTableNameEntity { @Id - @GeneratedValue long id; @Column(name = "`FieLd1`") String field1; @@ -229,7 +224,6 @@ public class SchemaUpdateTest { @Entity(name = "Match") public static class Match { @Id - @GeneratedValue long id; String match; @@ -242,7 +236,6 @@ public class SchemaUpdateTest { @Inheritance(strategy = InheritanceType.JOINED) public static class InheritanceRootEntity { @Id - @GeneratedValue protected Long id; }