From 5a2881261450fec2f805c88a4e1cb2f04e6df6a2 Mon Sep 17 00:00:00 2001
From: Guillaume Smet <guillaume.smet@gmail.com>
Date: Thu, 31 Mar 2022 12:07:25 +0200
Subject: [PATCH] Upgrade H2 to 2.1.210

Fixes #9354
---
 bom/application/pom.xml                       |  2 +-
 .../h2/deployment/H2DevServicesProcessor.java |  3 +-
 ...ayExtensionCleanAndMigrateAtStartTest.java |  4 +-
 .../test/FlywayExtensionCleanAtStartTest.java |  4 +-
 ...FlywayExtensionFilesystemResourceTest.java |  4 +-
 .../flyway/test/FlywayH2TestCustomizer.java   |  2 +-
 .../model/annotation/user/User.java           |  2 +
 .../model/config/user/User.java               |  2 +
 .../PublicFieldAccessAssociationsTest.java    |  2 +
 .../jdbc/h2/deployment/JDBCH2Processor.java   |  6 +++
 extensions/jdbc/jdbc-h2/runtime/pom.xml       |  2 +-
 .../jdbc/h2/runtime/graal/CompareMode.java    | 39 -------------------
 .../quarkus/jdbc/h2/runtime/graal/Engine.java |  9 +----
 ...nDisable.java => SessionLocalDisable.java} |  6 +--
 .../jdbc/h2/runtime/graal/SessionRemote.java  | 35 +++++++++++++++++
 ...seExtensionCleanAndMigrateAtStartTest.java |  9 +++--
 .../LiquibaseExtensionCleanAtStartTest.java   |  8 ++--
 .../spring/data/deployment/BasicTypeData.java |  2 +
 .../quarkus/spring/data/deployment/User.java  |  2 +
 .../src/test/resources/import_users.sql       |  2 +-
 .../quarkus/it/panache/TestEndpointRunner.kt  |  2 +-
 integration-tests/main/pom.xml                |  4 ++
 .../main/resources/META-INF/persistence.xml   |  2 +-
 .../it/spring/data/jpa/CatalogValue.java      |  2 +
 .../src/main/resources/import.sql             |  8 ++--
 .../test/h2/H2DatabaseTestResource.java       |  2 +-
 26 files changed, 92 insertions(+), 73 deletions(-)
 delete mode 100644 extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/CompareMode.java
 rename extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/{SessionDisable.java => SessionLocalDisable.java} (70%)
 create mode 100644 extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/SessionRemote.java

diff --git a/bom/application/pom.xml b/bom/application/pom.xml
index ff81bf68f6afa..6161d8f38aeb1 100644
--- a/bom/application/pom.xml
+++ b/bom/application/pom.xml
@@ -113,7 +113,7 @@
         <httpasync.version>4.1.5</httpasync.version>
         <cronutils.version>9.1.6</cronutils.version>
         <quartz.version>2.3.2</quartz.version>
-        <h2.version>1.4.197</h2.version>  <!-- keep 1.4.197 as newer versions have severe regressions -->
+        <h2.version>2.1.210</h2.version>
         <postgresql-jdbc.version>42.3.3</postgresql-jdbc.version>
         <mariadb-jdbc.version>3.0.4</mariadb-jdbc.version>
         <mysql-jdbc.version>8.0.28</mysql-jdbc.version>
diff --git a/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java b/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java
index 1489eccd1af19..9b4fb7a7200aa 100644
--- a/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java
+++ b/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java
@@ -34,7 +34,8 @@ public RunningDevServicesDatasource startDatabase(Optional<String> username, Opt
                     OptionalInt port, LaunchMode launchMode, Optional<Duration> startupTimeout) {
                 try {
                     final Server tcpServer = Server.createTcpServer("-tcpPort",
-                            port.isPresent() ? String.valueOf(port.getAsInt()) : "0");
+                            port.isPresent() ? String.valueOf(port.getAsInt()) : "0",
+                            "-ifNotExists");
                     tcpServer.start();
 
                     StringBuilder additionalArgs = new StringBuilder();
diff --git a/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionCleanAndMigrateAtStartTest.java b/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionCleanAndMigrateAtStartTest.java
index 4d3ddf97e0b10..fd0ca9159bf5b 100644
--- a/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionCleanAndMigrateAtStartTest.java
+++ b/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionCleanAndMigrateAtStartTest.java
@@ -11,7 +11,7 @@
 import javax.inject.Inject;
 
 import org.flywaydb.core.Flyway;
-import org.h2.jdbc.JdbcSQLException;
+import org.h2.jdbc.JdbcSQLSyntaxErrorException;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
@@ -40,7 +40,7 @@ public void testFlywayConfigInjection() throws SQLException {
         try (Connection connection = defaultDataSource.getConnection(); Statement stat = connection.createStatement()) {
             try (ResultSet executeQuery = stat.executeQuery("select * from fake_existing_tbl")) {
                 fail("fake_existing_tbl should not exist");
-            } catch (JdbcSQLException e) {
+            } catch (JdbcSQLSyntaxErrorException e) {
                 // expected fake_existing_tbl does not exist
             }
         }
diff --git a/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionCleanAtStartTest.java b/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionCleanAtStartTest.java
index bcb556266849e..72b9944c89a9f 100644
--- a/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionCleanAtStartTest.java
+++ b/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionCleanAtStartTest.java
@@ -12,7 +12,7 @@
 
 import org.flywaydb.core.Flyway;
 import org.flywaydb.core.api.MigrationInfo;
-import org.h2.jdbc.JdbcSQLException;
+import org.h2.jdbc.JdbcSQLSyntaxErrorException;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
@@ -41,7 +41,7 @@ public void testFlywayConfigInjection() throws SQLException {
         try (Connection connection = defaultDataSource.getConnection(); Statement stat = connection.createStatement()) {
             try (ResultSet executeQuery = stat.executeQuery("select * from fake_existing_tbl")) {
                 fail("fake_existing_tbl should not exist");
-            } catch (JdbcSQLException e) {
+            } catch (JdbcSQLSyntaxErrorException e) {
                 // expected fake_existing_tbl does not exist
             }
         }
diff --git a/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionFilesystemResourceTest.java b/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionFilesystemResourceTest.java
index bb1c8c6f0c004..e81138661eeaa 100644
--- a/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionFilesystemResourceTest.java
+++ b/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionFilesystemResourceTest.java
@@ -16,7 +16,7 @@
 import org.flywaydb.core.api.migration.BaseJavaMigration;
 import org.flywaydb.core.api.migration.Context;
 import org.flywaydb.core.api.migration.JavaMigration;
-import org.h2.jdbc.JdbcSQLException;
+import org.h2.jdbc.JdbcSQLSyntaxErrorException;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
@@ -45,7 +45,7 @@ public void testFlywayConfigInjection() throws SQLException {
         try (Connection connection = defaultDataSource.getConnection(); Statement stat = connection.createStatement()) {
             try (ResultSet executeQuery = stat.executeQuery("select * from fake_existing_tbl")) {
                 fail("fake_existing_tbl should not exist. Clean was run at start");
-            } catch (JdbcSQLException e) {
+            } catch (JdbcSQLSyntaxErrorException e) {
                 // expected fake_existing_tbl does not exist
             }
             try (ResultSet countQuery = stat.executeQuery("select count(1) from quarked_flyway")) {
diff --git a/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayH2TestCustomizer.java b/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayH2TestCustomizer.java
index 43ffd5c100a24..75ab8a1830b4f 100644
--- a/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayH2TestCustomizer.java
+++ b/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayH2TestCustomizer.java
@@ -38,7 +38,7 @@ public FlywayH2TestCustomizer withInitSqlFile(String initSqlFile) {
 
     void startH2() {
         try {
-            tcpServer = Server.createTcpServer("-tcpPort", String.valueOf(port));
+            tcpServer = Server.createTcpServer("-tcpPort", String.valueOf(port), "-ifNotExists");
             tcpServer.start();
             System.out.println("[INFO] Custom H2 database started in TCP server mode; server status: " + tcpServer.getStatus());
             if (initSqlFile != null) {
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/model/annotation/user/User.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/model/annotation/user/User.java
index 833bc4bc007e2..5071e3a692150 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/model/annotation/user/User.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/model/annotation/user/User.java
@@ -4,8 +4,10 @@
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
+import javax.persistence.Table;
 
 @Entity
+@Table(name = "User_")
 public class User {
 
     private long id;
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/model/config/user/User.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/model/config/user/User.java
index bc14b159e90ed..97689aadcf801 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/model/config/user/User.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/model/config/user/User.java
@@ -4,8 +4,10 @@
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
+import javax.persistence.Table;
 
 @Entity
+@Table(name = "User_")
 public class User {
 
     private long id;
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/publicfields/PublicFieldAccessAssociationsTest.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/publicfields/PublicFieldAccessAssociationsTest.java
index 47899dee9a8fe..d1501dcf4903c 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/publicfields/PublicFieldAccessAssociationsTest.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/publicfields/PublicFieldAccessAssociationsTest.java
@@ -6,6 +6,7 @@
 import java.util.List;
 
 import javax.inject.Inject;
+import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.EntityManager;
 import javax.persistence.GeneratedValue;
@@ -157,6 +158,7 @@ public static class ContainedEntity {
         @GeneratedValue
         public long id;
 
+        @Column(name = "value_")
         public String value;
 
         @OneToOne
diff --git a/extensions/jdbc/jdbc-h2/deployment/src/main/java/io/quarkus/jdbc/h2/deployment/JDBCH2Processor.java b/extensions/jdbc/jdbc-h2/deployment/src/main/java/io/quarkus/jdbc/h2/deployment/JDBCH2Processor.java
index 6b942aa719835..1f4d7239cf22f 100644
--- a/extensions/jdbc/jdbc-h2/deployment/src/main/java/io/quarkus/jdbc/h2/deployment/JDBCH2Processor.java
+++ b/extensions/jdbc/jdbc-h2/deployment/src/main/java/io/quarkus/jdbc/h2/deployment/JDBCH2Processor.java
@@ -13,6 +13,7 @@
 import io.quarkus.deployment.annotations.BuildStep;
 import io.quarkus.deployment.builditem.FeatureBuildItem;
 import io.quarkus.deployment.builditem.SslNativeConfigBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
 import io.quarkus.jdbc.h2.runtime.H2AgroalConnectionConfigurer;
 
 public class JDBCH2Processor {
@@ -49,4 +50,9 @@ void configureAgroalConnection(BuildProducer<AdditionalBeanBuildItem> additional
     void registerDefaultDbType(BuildProducer<DefaultDataSourceDbKindBuildItem> dbKind) {
         dbKind.produce(new DefaultDataSourceDbKindBuildItem(DatabaseKind.H2));
     }
+
+    @BuildStep
+    void runtimeInitializedClasses(BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitializedClasses) {
+        runtimeInitializedClasses.produce(new RuntimeInitializedClassBuildItem("org.h2.store.fs.niomem.FileNioMemData"));
+    }
 }
diff --git a/extensions/jdbc/jdbc-h2/runtime/pom.xml b/extensions/jdbc/jdbc-h2/runtime/pom.xml
index 2d9da9183b185..a0681c7c207e3 100644
--- a/extensions/jdbc/jdbc-h2/runtime/pom.xml
+++ b/extensions/jdbc/jdbc-h2/runtime/pom.xml
@@ -24,7 +24,7 @@
         <dependency>
             <groupId>org.locationtech.jts</groupId>
             <artifactId>jts-core</artifactId>
-            <version>1.15.0</version>
+            <version>1.17.0</version>
             <!--
                 TODO: Make this an optional dependency?
                 Graal compiler not happy with broken classpaths
diff --git a/extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/CompareMode.java b/extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/CompareMode.java
deleted file mode 100644
index 49eed7216a070..0000000000000
--- a/extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/CompareMode.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package io.quarkus.jdbc.h2.runtime.graal;
-
-import org.h2.engine.SysProperties;
-
-import com.oracle.svm.core.annotate.Alias;
-import com.oracle.svm.core.annotate.Substitute;
-import com.oracle.svm.core.annotate.TargetClass;
-
-@TargetClass(org.h2.value.CompareMode.class)
-public final class CompareMode {
-
-    @Alias
-    private static volatile CompareMode lastUsed;
-
-    //    @Inject
-    //    private static final org.h2.value.CompareMode SINGLE_CHOICE = org.h2.value.CompareMode.getInstance(null, 0, SysProperties.SORT_BINARY_UNSIGNED);
-
-    @Substitute
-    public static CompareMode getInstance(String name, int strength, boolean binaryUnsigned) {
-        if (name != null || strength != 0 || binaryUnsigned != SysProperties.SORT_BINARY_UNSIGNED) {
-            throw new UnsupportedOperationException(
-                    "Only the default Collator can be currently used in native mode; see https://github.com/oracle/graal/issues/839");
-        }
-        CompareMode var3 = lastUsed;
-        if (var3 == null) {
-            var3 = new CompareMode(name, strength, binaryUnsigned);
-            lastUsed = var3;
-        }
-        return var3;
-        //TODO?: Can't create a singleton via @Inject
-        //return SINGLE_CHOICE;
-    }
-
-    @Alias
-    protected CompareMode(String var1, int var2, boolean var3) {
-        //Uses the original code
-    }
-
-}
diff --git a/extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/Engine.java b/extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/Engine.java
index 3fff2fd609fb6..28d954929f296 100644
--- a/extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/Engine.java
+++ b/extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/Engine.java
@@ -11,18 +11,13 @@
 public final class Engine {
 
     @Substitute
-    public static Engine getInstance() {
-        return new Engine();
-    }
-
-    @Substitute
-    public Session createSession(ConnectionInfo ci) {
+    public static Session createSession(ConnectionInfo ci) {
         throw new UnsupportedOperationException(
                 "H2 database compiled into a native-image is only functional as a client: can't create an Embedded Database Session");
     }
 
     @Substitute
-    void close(String name) {
+    static void close(String name) {
         //no-op
     }
 
diff --git a/extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/SessionDisable.java b/extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/SessionLocalDisable.java
similarity index 70%
rename from extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/SessionDisable.java
rename to extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/SessionLocalDisable.java
index fa38a3facdd7a..ea45d89d5d3e9 100644
--- a/extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/SessionDisable.java
+++ b/extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/SessionLocalDisable.java
@@ -4,13 +4,13 @@
 import com.oracle.svm.core.annotate.TargetClass;
 
 /**
- * The org.h2.engine.Session represents the "Embedded Database" in H2.
+ * The org.h2.engine.SessionLocal represents the "Embedded Database" in H2.
  * We remove this explicitly as it pulls in various things we can't support;
  * rather than address them individually it's simpler to make sure this
  * Session doesn't get included by mistake: that will produce errors
  * that are easier to manage.
  */
-@TargetClass(className = "org.h2.engine.Session")
+@TargetClass(className = "org.h2.engine.SessionLocal")
 @Delete
-public final class SessionDisable {
+public final class SessionLocalDisable {
 }
diff --git a/extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/SessionRemote.java b/extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/SessionRemote.java
new file mode 100644
index 0000000000000..1a910c68d0871
--- /dev/null
+++ b/extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/SessionRemote.java
@@ -0,0 +1,35 @@
+package io.quarkus.jdbc.h2.runtime.graal;
+
+import org.h2.engine.ConnectionInfo;
+import org.h2.engine.Session;
+
+import com.oracle.svm.core.annotate.Alias;
+import com.oracle.svm.core.annotate.Substitute;
+import com.oracle.svm.core.annotate.TargetClass;
+
+@TargetClass(className = "org.h2.engine.SessionRemote")
+public final class SessionRemote {
+
+    @Alias
+    private ConnectionInfo connectionInfo;
+
+    /**
+     * Even if in SessionRemote, this method originally can instantiate a local engine.
+     * We don't want that as we don't support a local engine.
+     */
+    @Substitute
+    public Session connectEmbeddedOrServer(boolean openNew) {
+        ConnectionInfo ci = connectionInfo;
+        if (ci.isRemote()) {
+            connectServer(ci);
+            return (Session) (Object) this;
+        }
+
+        throw new UnsupportedOperationException(
+                "H2 database compiled into a native-image is only functional as a client: can't create an Embedded Database Session");
+    }
+
+    @Alias
+    private void connectServer(ConnectionInfo ci) {
+    }
+}
diff --git a/extensions/liquibase/deployment/src/test/java/io/quarkus/liquibase/test/LiquibaseExtensionCleanAndMigrateAtStartTest.java b/extensions/liquibase/deployment/src/test/java/io/quarkus/liquibase/test/LiquibaseExtensionCleanAndMigrateAtStartTest.java
index cf4f75d12726b..a2e0250486f9b 100644
--- a/extensions/liquibase/deployment/src/test/java/io/quarkus/liquibase/test/LiquibaseExtensionCleanAndMigrateAtStartTest.java
+++ b/extensions/liquibase/deployment/src/test/java/io/quarkus/liquibase/test/LiquibaseExtensionCleanAndMigrateAtStartTest.java
@@ -1,6 +1,9 @@
 package io.quarkus.liquibase.test;
 
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.sql.Connection;
 import java.sql.ResultSet;
@@ -9,7 +12,7 @@
 
 import javax.inject.Inject;
 
-import org.h2.jdbc.JdbcSQLException;
+import org.h2.jdbc.JdbcSQLSyntaxErrorException;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
@@ -42,7 +45,7 @@ public void testLiquibaseConfigInjection() throws Exception {
             try (ResultSet executeQuery = stat
                     .executeQuery("select * from fake_existing_tbl")) {
                 fail("fake_existing_tbl should not exist");
-            } catch (JdbcSQLException e) {
+            } catch (JdbcSQLSyntaxErrorException e) {
                 // expected fake_existing_tbl does not exist
             }
         }
diff --git a/extensions/liquibase/deployment/src/test/java/io/quarkus/liquibase/test/LiquibaseExtensionCleanAtStartTest.java b/extensions/liquibase/deployment/src/test/java/io/quarkus/liquibase/test/LiquibaseExtensionCleanAtStartTest.java
index 1562a147f2211..f6a867188406a 100644
--- a/extensions/liquibase/deployment/src/test/java/io/quarkus/liquibase/test/LiquibaseExtensionCleanAtStartTest.java
+++ b/extensions/liquibase/deployment/src/test/java/io/quarkus/liquibase/test/LiquibaseExtensionCleanAtStartTest.java
@@ -1,7 +1,9 @@
 package io.quarkus.liquibase.test;
 
-import static org.junit.jupiter.api.Assertions.*;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.sql.Connection;
 import java.sql.ResultSet;
@@ -10,7 +12,7 @@
 
 import javax.inject.Inject;
 
-import org.h2.jdbc.JdbcSQLException;
+import org.h2.jdbc.JdbcSQLSyntaxErrorException;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
@@ -43,7 +45,7 @@ public void testLiquibaseConfigInjection() throws Exception {
             try (ResultSet executeQuery = stat
                     .executeQuery("select * from fake_existing_tbl")) {
                 fail("fake_existing_tbl should not exist");
-            } catch (JdbcSQLException e) {
+            } catch (JdbcSQLSyntaxErrorException e) {
                 // expected fake_existing_tbl does not exist
             }
         }
diff --git a/extensions/spring-data-jpa/deployment/src/test/java/io/quarkus/spring/data/deployment/BasicTypeData.java b/extensions/spring-data-jpa/deployment/src/test/java/io/quarkus/spring/data/deployment/BasicTypeData.java
index 7cb157b46a4f8..b158524796939 100644
--- a/extensions/spring-data-jpa/deployment/src/test/java/io/quarkus/spring/data/deployment/BasicTypeData.java
+++ b/extensions/spring-data-jpa/deployment/src/test/java/io/quarkus/spring/data/deployment/BasicTypeData.java
@@ -7,6 +7,7 @@
 import java.util.TimeZone;
 import java.util.UUID;
 
+import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
@@ -24,6 +25,7 @@ public class BasicTypeData {
     private TimeZone timeZone;
     private java.net.URL url;
     private Class clazz;
+    @Column(length = 16)
     private java.util.UUID uuid;
     private Duration duration;
 
diff --git a/extensions/spring-data-jpa/deployment/src/test/java/io/quarkus/spring/data/deployment/User.java b/extensions/spring-data-jpa/deployment/src/test/java/io/quarkus/spring/data/deployment/User.java
index 6aa3dba4a41dc..b37799f1af191 100644
--- a/extensions/spring-data-jpa/deployment/src/test/java/io/quarkus/spring/data/deployment/User.java
+++ b/extensions/spring-data-jpa/deployment/src/test/java/io/quarkus/spring/data/deployment/User.java
@@ -10,8 +10,10 @@
 import javax.persistence.NamedQueries;
 import javax.persistence.NamedQuery;
 import javax.persistence.OneToMany;
+import javax.persistence.Table;
 
 @Entity
+@Table(name = "User_")
 @NamedQuery(name = "User.getUserByFullNameUsingNamedQuery", query = "select u from User u where u.fullName=:name")
 @NamedQueries(@NamedQuery(name = "User.getUserByFullNameUsingNamedQueries", query = "select u from User u where u.fullName=:name"))
 public class User {
diff --git a/extensions/spring-data-jpa/deployment/src/test/resources/import_users.sql b/extensions/spring-data-jpa/deployment/src/test/resources/import_users.sql
index 9d622a8d08d49..631db367f8cee 100644
--- a/extensions/spring-data-jpa/deployment/src/test/resources/import_users.sql
+++ b/extensions/spring-data-jpa/deployment/src/test/resources/import_users.sql
@@ -1 +1 @@
-INSERT INTO user(userid, fullname, logincounter, active) VALUES ('JOHN', 'John Doe', 0, true);
\ No newline at end of file
+INSERT INTO user_(userid, fullname, logincounter, active) VALUES ('JOHN', 'John Doe', 0, true);
\ No newline at end of file
diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/TestEndpointRunner.kt b/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/TestEndpointRunner.kt
index 5d2a177963cf8..19548cf4d25e7 100644
--- a/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/TestEndpointRunner.kt
+++ b/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/TestEndpointRunner.kt
@@ -41,7 +41,7 @@ class TestEndpointRunner {
         }
         con.close()
 
-        Assertions.assertEquals("VARCHAR", schema["PERSON2"]?.get("STATUS"), schema.toString())
+        Assertions.assertEquals("CHARACTER VARYING", schema["PERSON2"]?.get("STATUS"), schema.toString())
 
         endpoint.testModelDao()
         endpoint.testModel()
diff --git a/integration-tests/main/pom.xml b/integration-tests/main/pom.xml
index 372baa2f67660..966356cb77d49 100644
--- a/integration-tests/main/pom.xml
+++ b/integration-tests/main/pom.xml
@@ -19,6 +19,8 @@
         <datasource.username></datasource.username>
         <datasource.password></datasource.password>
 
+        <hibernate-orm.dialect>org.hibernate.dialect.H2Dialect</hibernate-orm.dialect>
+
         <!-- do not update this dependency, it is only used for testing -->
         <webjar.jquery-ui.version>1.13.0</webjar.jquery-ui.version>
     </properties>
@@ -526,6 +528,8 @@
                 <datasource.url>${postgres.url}</datasource.url>
                 <datasource.username>hibernate_orm_test</datasource.username>
                 <datasource.password>hibernate_orm_test</datasource.password>
+
+                <hibernate-orm.dialect>org.hibernate.dialect.PostgreSQL10Dialect</hibernate-orm.dialect>
             </properties>
             <dependencies>
                 <dependency>
diff --git a/integration-tests/main/src/main/resources/META-INF/persistence.xml b/integration-tests/main/src/main/resources/META-INF/persistence.xml
index 956cee5c6cbaf..843270ea08740 100644
--- a/integration-tests/main/src/main/resources/META-INF/persistence.xml
+++ b/integration-tests/main/src/main/resources/META-INF/persistence.xml
@@ -15,7 +15,7 @@
             <property name="hibernate.archive.autodetection" value="class, hbm"/>
 
             <!-- Connection specific -->
-            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL95Dialect"/>
+            <property name="hibernate.dialect" value="${hibernate-orm.dialect}"/>
 
             <!-- Tuning and debugging -->
             <property name="hibernate.connection.pool_size" value="2"/>
diff --git a/integration-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/CatalogValue.java b/integration-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/CatalogValue.java
index b813292c0494f..dd80005feeafe 100644
--- a/integration-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/CatalogValue.java
+++ b/integration-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/CatalogValue.java
@@ -1,5 +1,6 @@
 package io.quarkus.it.spring.data.jpa;
 
+import javax.persistence.Column;
 import javax.persistence.DiscriminatorColumn;
 import javax.persistence.Entity;
 import javax.persistence.Inheritance;
@@ -10,6 +11,7 @@
 @DiscriminatorColumn(name = "type")
 public class CatalogValue extends AbstractEntity {
 
+    @Column(name = "key_")
     private String key;
     private String displayName;
 
diff --git a/integration-tests/spring-data-jpa/src/main/resources/import.sql b/integration-tests/spring-data-jpa/src/main/resources/import.sql
index fb21121789cec..6fce9bd2a3b34 100644
--- a/integration-tests/spring-data-jpa/src/main/resources/import.sql
+++ b/integration-tests/spring-data-jpa/src/main/resources/import.sql
@@ -87,7 +87,7 @@ INSERT INTO MotorCar(id, brand, model) VALUES (1, 'Monteverdi', 'Hai 450');
 INSERT INTO MotorCar(id, brand, model) VALUES (2, 'Rinspeed', 'iChange');
 INSERT INTO MotorCar(id, brand, model) VALUES (3, 'Rinspeed', 'Oasis');
 
-INSERT INTO CatalogValue(id, key, displayName, type) VALUES (1, 'DE-BY', 'Bavaria', 'federalState');
-INSERT INTO CatalogValue(id, key, displayName, type) VALUES (2, 'DE-SN', 'Saxony', 'federalState');
-INSERT INTO CatalogValue(id, key, displayName, type) VALUES (3, 'DE', 'Germany', 'country');
-INSERT INTO CatalogValue(id, key, displayName, type) VALUES (4, 'FR', 'France', 'country');
+INSERT INTO CatalogValue(id, key_, displayName, type) VALUES (1, 'DE-BY', 'Bavaria', 'federalState');
+INSERT INTO CatalogValue(id, key_, displayName, type) VALUES (2, 'DE-SN', 'Saxony', 'federalState');
+INSERT INTO CatalogValue(id, key_, displayName, type) VALUES (3, 'DE', 'Germany', 'country');
+INSERT INTO CatalogValue(id, key_, displayName, type) VALUES (4, 'FR', 'France', 'country');
diff --git a/test-framework/h2/src/main/java/io/quarkus/test/h2/H2DatabaseTestResource.java b/test-framework/h2/src/main/java/io/quarkus/test/h2/H2DatabaseTestResource.java
index 85841c3d03f09..10749366b1824 100644
--- a/test-framework/h2/src/main/java/io/quarkus/test/h2/H2DatabaseTestResource.java
+++ b/test-framework/h2/src/main/java/io/quarkus/test/h2/H2DatabaseTestResource.java
@@ -16,7 +16,7 @@ public class H2DatabaseTestResource implements QuarkusTestResourceLifecycleManag
     public Map<String, String> start() {
 
         try {
-            tcpServer = Server.createTcpServer();
+            tcpServer = Server.createTcpServer("-ifNotExists");
             tcpServer.start();
             System.out.println("[INFO] H2 database started in TCP server mode; server status: " + tcpServer.getStatus());
         } catch (SQLException e) {