Skip to content

Commit 94c2703

Browse files
committed
[hibernate#929] H2 module integration
1 parent 124e8c7 commit 94c2703

File tree

6 files changed

+20
-5
lines changed

6 files changed

+20
-5
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ org.gradle.java.installations.auto-download=false
2626

2727
# The database type to use (key insensitive and support aliases):
2828
# Db2, MySql, PostgreSQL, CockroachDB, SqlServer
29-
#db = MSSQL
29+
db = H2
3030

3131
# Enable the SonatypeOS maven repository (mainly for Vert.x snapshots) when present (value ignored)
3232
#enableSonatypeOpenSourceSnapshotsRep = true

hibernate-reactive-core/build.gradle

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ext {
2-
mavenPomName = 'Hibernate Reactive Core'
2+
mavenPomName = 'Hibernate Reactive Core'
33
}
44

55
description = 'The core module of Hibernate Reactive'
@@ -31,6 +31,8 @@ dependencies {
3131
testImplementation 'org.assertj:assertj-core:3.20.2'
3232
testImplementation "io.vertx:vertx-unit:${vertxVersion}"
3333

34+
testImplementation project(':hibernate-reactive-h2')
35+
3436
// Drivers
3537
testImplementation "io.vertx:vertx-pg-client:${vertxVersion}"
3638
testImplementation "io.vertx:vertx-mysql-client:${vertxVersion}"

hibernate-reactive-core/src/main/java/org/hibernate/reactive/pool/impl/DefaultSqlClientPoolConfiguration.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ public class DefaultSqlClientPoolConfiguration implements SqlClientPoolConfigura
4949
private String user;
5050
private String pass;
5151

52+
protected String getUser() {
53+
return user;
54+
}
55+
56+
protected String getPassword() {
57+
return pass;
58+
}
59+
5260
@Override
5361
public void configure(Map configuration) {
5462
user = getString( Settings.USER, configuration );
@@ -101,7 +109,7 @@ public SqlConnectOptions connectOptions(URI uri) {
101109
: "";
102110

103111
if ( scheme.equals( "db2" ) && database.indexOf( ':' ) > 0 ) {
104-
// DB2 URLs are a bit odd and have the format:
112+
// DB2 URLs are a bit odd and have the format:-
105113
// jdbc:db2://<HOST>:<PORT>/<DB>:key1=value1;key2=value2;
106114
database = database.substring( 0, database.indexOf( ':' ) );
107115
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/pool/impl/ReactiveConnectionPoolInitiator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public ReactiveConnectionPoolInitiator() {}
3838
@Override
3939
public ReactiveConnectionPool initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
4040
Object configValue = configurationValues.get( Settings.SQL_CLIENT_POOL );
41-
if (configValue==null) {
41+
if ( configValue == null ) {
4242
return new DefaultSqlClientPool();
4343
}
4444

hibernate-reactive-core/src/main/java/org/hibernate/reactive/provider/service/NoJdbcEnvironmentInitiator.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.hibernate.dialect.CockroachDB201Dialect;
1010
import org.hibernate.dialect.DB297Dialect;
1111
import org.hibernate.dialect.Dialect;
12+
import org.hibernate.dialect.H2Dialect;
1213
import org.hibernate.dialect.MariaDB103Dialect;
1314
import org.hibernate.dialect.MySQL8Dialect;
1415
import org.hibernate.dialect.Oracle12cDialect;
@@ -35,7 +36,7 @@
3536
/**
3637
* A Hibernate {@link StandardServiceInitiator service initiator} that
3738
* provides an implementation of {@link JdbcEnvironment} that infers
38-
* the Hibernate {@link org.hibernate.dialect.Dialect} from the JDBC URL.
39+
* the Hibernate {@link Dialect} from the JDBC URL.
3940
*/
4041
public class NoJdbcEnvironmentInitiator extends JdbcEnvironmentInitiator {
4142
private static final Log LOG = LoggerFactory.make( Log.class, MethodHandles.lookup() );
@@ -147,6 +148,9 @@ else if ( url.startsWith( "sqlserver:" ) ) {
147148
else if ( url.startsWith( "oracle:" ) ) {
148149
return Oracle12cDialect.class;
149150
}
151+
else if ( url.startsWith( "h2:" ) ) {
152+
return H2Dialect.class;
153+
}
150154
else {
151155
return null;
152156
}

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ logger.lifecycle "Java versions for main code: " + gradle.ext.javaVersions.main
8282
logger.lifecycle "Java versions for tests: " + gradle.ext.javaVersions.test
8383

8484
include 'hibernate-reactive-core'
85+
include 'hibernate-reactive-h2'
8586
include 'session-example'
8687
include 'native-sql-example'
8788
include 'verticle-postgres-it'

0 commit comments

Comments
 (0)