org.hibernate.testing.env.TestingDatabaseInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-testing Show documentation
Show all versions of hibernate-testing Show documentation
Support for testing Hibernate ORM functionality
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.testing.env;
import java.util.function.BiConsumer;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.cfg.JdbcSettings;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.H2Dialect;
/**
* @author Steve Ebersole
*/
public final class TestingDatabaseInfo {
public static volatile String DRIVER = "org.h2.Driver";
public static volatile String URL = "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE";
public static volatile String USER = "sa";
public static volatile String PASS = "";
public static final Dialect DIALECT = new H2Dialect();
public static void forEachSetting(BiConsumer consumer) {
consumer.accept( JdbcSettings.JAKARTA_JDBC_DRIVER, DRIVER );
consumer.accept( JdbcSettings.JAKARTA_JDBC_URL, URL );
consumer.accept( JdbcSettings.JAKARTA_JDBC_USER, USER );
consumer.accept( JdbcSettings.JAKARTA_JDBC_PASSWORD, PASS );
consumer.accept( JdbcSettings.DIALECT, DIALECT.getClass().getName() );
}
public static Configuration buildBaseConfiguration() {
final Configuration configuration = new Configuration();
forEachSetting( configuration::setProperty );
return configuration;
}
private TestingDatabaseInfo() {
}
}