diff --git a/integrationtest/mapper/orm-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/outboxpolling/schema/OutboxPollingCustomEntityMappingIT.java b/integrationtest/mapper/orm-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/outboxpolling/schema/OutboxPollingCustomEntityMappingIT.java index 58c65cc534e..5edf90697b5 100644 --- a/integrationtest/mapper/orm-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/outboxpolling/schema/OutboxPollingCustomEntityMappingIT.java +++ b/integrationtest/mapper/orm-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/outboxpolling/schema/OutboxPollingCustomEntityMappingIT.java @@ -55,9 +55,6 @@ class OutboxPollingCustomEntityMappingIT { - private static final String POSTGRESQL_DIALECT = "org.hibernate.dialect.PostgreSQLDialect"; - private static final String MSSQL_DIALECT = "org.hibernate.dialect.SQLServerDialect"; - private static final String CUSTOM_SCHEMA = "CUSTOM_SCHEMA"; private static final String ORIGINAL_OUTBOX_EVENT_TABLE_NAME = HibernateOrmMapperOutboxPollingSettings.Defaults.COORDINATION_ENTITY_MAPPING_OUTBOX_EVENT_TABLE; @@ -417,18 +414,14 @@ void defaultUuidDataType() { JdbcType agent = idJdbcType( sessionFactory, Agent.class ); JdbcType event = idJdbcType( sessionFactory, OutboxEvent.class ); - String dialect = DatabaseContainer.configuration().dialect(); - - switch ( dialect ) { - case POSTGRESQL_DIALECT: - case MSSQL_DIALECT: - assertThat( agent.getDdlTypeCode() ).isEqualTo( SqlTypes.UUID ); - assertThat( event.getDdlTypeCode() ).isEqualTo( SqlTypes.UUID ); - break; - default: - assertThat( agent.getDdlTypeCode() ).isIn( SqlTypes.UUID, SqlTypes.BINARY, SqlTypes.CHAR ); - assertThat( event.getDdlTypeCode() ).isIn( SqlTypes.UUID, SqlTypes.BINARY, SqlTypes.CHAR ); - break; + if ( DatabaseContainer.configuration().is( DatabaseContainer.SupportedDatabase.POSTGRES, + DatabaseContainer.SupportedDatabase.MSSQL ) ) { + assertThat( agent.getDdlTypeCode() ).isEqualTo( SqlTypes.UUID ); + assertThat( event.getDdlTypeCode() ).isEqualTo( SqlTypes.UUID ); + } + else { + assertThat( agent.getDdlTypeCode() ).isIn( SqlTypes.UUID, SqlTypes.BINARY, SqlTypes.CHAR ); + assertThat( event.getDdlTypeCode() ).isIn( SqlTypes.UUID, SqlTypes.BINARY, SqlTypes.CHAR ); } } diff --git a/integrationtest/mapper/orm-spring-uberjar/application/src/main/resources/application.yaml b/integrationtest/mapper/orm-spring-uberjar/application/src/main/resources/application.yaml index 04b67875966..9fc02f39214 100644 --- a/integrationtest/mapper/orm-spring-uberjar/application/src/main/resources/application.yaml +++ b/integrationtest/mapper/orm-spring-uberjar/application/src/main/resources/application.yaml @@ -1,7 +1,5 @@ spring.jpa: properties: - hibernate: - dialect: org.hibernate.dialect.H2Dialect hibernate.search: backend: directory.root: ${LUCENE_ROOT_PATH:target/test-indexes}/${random.uuid} @@ -10,4 +8,4 @@ spring.datasource: driver-class-name: org.h2.Driver url: jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1 username: sa - password: sa \ No newline at end of file + password: sa diff --git a/util/internal/integrationtest/mapper/orm/src/main/java/org/hibernate/search/util/impl/integrationtest/mapper/orm/DatabaseContainer.java b/util/internal/integrationtest/mapper/orm/src/main/java/org/hibernate/search/util/impl/integrationtest/mapper/orm/DatabaseContainer.java index 75b6cee760e..841923b1a71 100644 --- a/util/internal/integrationtest/mapper/orm/src/main/java/org/hibernate/search/util/impl/integrationtest/mapper/orm/DatabaseContainer.java +++ b/util/internal/integrationtest/mapper/orm/src/main/java/org/hibernate/search/util/impl/integrationtest/mapper/orm/DatabaseContainer.java @@ -62,14 +62,12 @@ public static Configuration configuration() { // Let's see if an external DB connection was provided: String url = System.getProperty( "jdbc.url" ); if ( url != null && !url.trim().isEmpty() ) { - // -Dhibernate.dialect=${db.dialect} // -Dhibernate.connection.driver_class=${jdbc.driver} // -Dhibernate.connection.url=${jdbc.url} // -Dhibernate.connection.username=${jdbc.user} // -Dhibernate.connection.password=${jdbc.pass} // -Dhibernate.connection.isolation=${jdbc.isolation} return DATABASE.configuration( url, DATABASE_CONTAINER ) - .withDialect( System.getProperty( "db.dialect" ) ) .withDriver( System.getProperty( "jdbc.driver" ) ) .withUser( System.getProperty( "jdbc.user" ) ) .withPass( System.getProperty( "jdbc.pass" ) ) @@ -97,7 +95,7 @@ String dialect() { @Override Configuration configuration(JdbcDatabaseContainer container) { return new Configuration( - dialect(), + this, "org.h2.Driver", "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1", "sa", @@ -317,7 +315,7 @@ protected void containerIsStarted(InspectContainerResponse containerInfo) { Configuration configuration(JdbcDatabaseContainer container) { return new Configuration( - dialect(), + this, container.getDriverClassName(), container.getJdbcUrl(), container.getUsername(), @@ -328,7 +326,7 @@ Configuration configuration(JdbcDatabaseContainer container) { Configuration configuration(String jdbcUrl, JdbcDatabaseContainer container) { return new Configuration( - dialect(), + this, container.getDriverClassName(), jdbcUrl, container.getUsername(), @@ -439,15 +437,16 @@ protected String getTestQueryString() { public static class Configuration { - private final String dialect; + private final DatabaseContainer.SupportedDatabase database; private final String driver; private final String url; private final String user; private final String pass; private final String isolation; - private Configuration(String dialect, String driver, String url, String user, String pass, String isolation) { - this.dialect = dialect; + private Configuration(DatabaseContainer.SupportedDatabase database, String driver, String url, String user, String pass, + String isolation) { + this.database = database; this.driver = driver; this.url = url; this.user = user; @@ -455,10 +454,6 @@ private Configuration(String dialect, String driver, String url, String user, St this.isolation = isolation; } - public String dialect() { - return dialect; - } - public String driver() { return driver; } @@ -480,12 +475,12 @@ public String isolation() { } public boolean is(DatabaseContainer.SupportedDatabase database) { - return database.dialect().equals( dialect ); + return this.database.equals( database ); } public boolean is(DatabaseContainer.SupportedDatabase... databases) { for ( SupportedDatabase database : databases ) { - if ( database.dialect().equals( dialect ) ) { + if ( this.database.equals( database ) ) { return true; } } @@ -494,7 +489,6 @@ public boolean is(DatabaseContainer.SupportedDatabase... databases) { @SuppressWarnings("deprecation") // since DialectContext is using the deprecated properties we cannot switch to JAKARTA_* for now... public void add(Map map) { - map.put( JdbcSettings.DIALECT, this.dialect ); map.put( JdbcSettings.DRIVER, this.driver ); map.put( JdbcSettings.URL, this.url ); map.put( JdbcSettings.USER, this.user ); @@ -509,46 +503,39 @@ public void addAsSpring(BiConsumer consumer) { consumer.accept( "spring.datasource.password", this.pass ); } - private Configuration withDialect(String dialect) { - if ( dialect == null ) { - return this; - } - return new Configuration( dialect, driver, url, user, pass, isolation ); - } - private Configuration withDriver(String driver) { if ( driver == null ) { return this; } - return new Configuration( dialect, driver, url, user, pass, isolation ); + return new Configuration( database, driver, url, user, pass, isolation ); } private Configuration withUrl(String url) { if ( url == null ) { return this; } - return new Configuration( dialect, driver, url, user, pass, isolation ); + return new Configuration( database, driver, url, user, pass, isolation ); } private Configuration withUser(String user) { if ( user == null ) { return this; } - return new Configuration( dialect, driver, url, user, pass, isolation ); + return new Configuration( database, driver, url, user, pass, isolation ); } private Configuration withPass(String pass) { if ( pass == null ) { return this; } - return new Configuration( dialect, driver, url, user, pass, isolation ); + return new Configuration( database, driver, url, user, pass, isolation ); } private Configuration withIsolation(String isolation) { if ( isolation == null ) { return this; } - return new Configuration( dialect, driver, url, user, pass, isolation ); + return new Configuration( database, driver, url, user, pass, isolation ); } } }