Skip to content

Commit

Permalink
[hibernate#929] H2 module integration
Browse files Browse the repository at this point in the history
  • Loading branch information
blafond committed Mar 31, 2022
1 parent 124e8c7 commit 94c2703
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ org.gradle.java.installations.auto-download=false

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

# Enable the SonatypeOS maven repository (mainly for Vert.x snapshots) when present (value ignored)
#enableSonatypeOpenSourceSnapshotsRep = true
Expand Down
4 changes: 3 additions & 1 deletion hibernate-reactive-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ext {
mavenPomName = 'Hibernate Reactive Core'
mavenPomName = 'Hibernate Reactive Core'
}

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

testImplementation project(':hibernate-reactive-h2')

// Drivers
testImplementation "io.vertx:vertx-pg-client:${vertxVersion}"
testImplementation "io.vertx:vertx-mysql-client:${vertxVersion}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public class DefaultSqlClientPoolConfiguration implements SqlClientPoolConfigura
private String user;
private String pass;

protected String getUser() {
return user;
}

protected String getPassword() {
return pass;
}

@Override
public void configure(Map configuration) {
user = getString( Settings.USER, configuration );
Expand Down Expand Up @@ -101,7 +109,7 @@ public SqlConnectOptions connectOptions(URI uri) {
: "";

if ( scheme.equals( "db2" ) && database.indexOf( ':' ) > 0 ) {
// DB2 URLs are a bit odd and have the format:
// DB2 URLs are a bit odd and have the format:-
// jdbc:db2://<HOST>:<PORT>/<DB>:key1=value1;key2=value2;
database = database.substring( 0, database.indexOf( ':' ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ReactiveConnectionPoolInitiator() {}
@Override
public ReactiveConnectionPool initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
Object configValue = configurationValues.get( Settings.SQL_CLIENT_POOL );
if (configValue==null) {
if ( configValue == null ) {
return new DefaultSqlClientPool();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.hibernate.dialect.CockroachDB201Dialect;
import org.hibernate.dialect.DB297Dialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.MariaDB103Dialect;
import org.hibernate.dialect.MySQL8Dialect;
import org.hibernate.dialect.Oracle12cDialect;
Expand All @@ -35,7 +36,7 @@
/**
* A Hibernate {@link StandardServiceInitiator service initiator} that
* provides an implementation of {@link JdbcEnvironment} that infers
* the Hibernate {@link org.hibernate.dialect.Dialect} from the JDBC URL.
* the Hibernate {@link Dialect} from the JDBC URL.
*/
public class NoJdbcEnvironmentInitiator extends JdbcEnvironmentInitiator {
private static final Log LOG = LoggerFactory.make( Log.class, MethodHandles.lookup() );
Expand Down Expand Up @@ -147,6 +148,9 @@ else if ( url.startsWith( "sqlserver:" ) ) {
else if ( url.startsWith( "oracle:" ) ) {
return Oracle12cDialect.class;
}
else if ( url.startsWith( "h2:" ) ) {
return H2Dialect.class;
}
else {
return null;
}
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ logger.lifecycle "Java versions for main code: " + gradle.ext.javaVersions.main
logger.lifecycle "Java versions for tests: " + gradle.ext.javaVersions.test

include 'hibernate-reactive-core'
include 'hibernate-reactive-h2'
include 'session-example'
include 'native-sql-example'
include 'verticle-postgres-it'
Expand Down

0 comments on commit 94c2703

Please sign in to comment.