All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.testing.env.TestingDatabaseInfo Maven / Gradle / Ivy

There is a newer version: 7.0.0.Beta2
Show newest version
/*
 * 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() {
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy