use of org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl in project hibernate-orm by hibernate.
the class IndividuallySchemaValidatorImplTest method testMissingColumn.
@Test
public void testMissingColumn() throws Exception {
MetadataSources metadataSources = new MetadataSources(ssr);
metadataSources.addAnnotatedClass(NoNameColumn.class);
MetadataImplementor metadata = (MetadataImplementor) metadataSources.buildMetadata();
metadata.validate();
Map<String, Object> settings = new HashMap<>();
ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) new StandardServiceRegistryBuilder().applySettings(settings).build();
DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl();
connectionProvider.configure(properties());
final GenerationTargetToDatabase schemaGenerator = new GenerationTargetToDatabase(new DdlTransactionIsolatorTestingImpl(serviceRegistry, new JdbcConnectionAccessImpl(connectionProvider)));
try {
new SchemaCreatorImpl(ssr).doCreation(metadata, serviceRegistry, settings, true, schemaGenerator);
metadataSources = new MetadataSources(ssr);
metadataSources.addAnnotatedClass(NameColumn.class);
metadata = (MetadataImplementor) metadataSources.buildMetadata();
metadata.validate();
try {
getSchemaValidator(metadata);
Assert.fail("SchemaManagementException expected");
} catch (SchemaManagementException e) {
assertEquals("Schema-validation: missing column [name] in table [SomeSchema.ColumnEntity]", e.getMessage());
}
} finally {
new SchemaDropperImpl(serviceRegistry).doDrop(metadata, false, schemaGenerator);
serviceRegistry.destroy();
connectionProvider.stop();
}
}
use of org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl in project hibernate-orm by hibernate.
the class ConnectionProviderBuilder method buildConnectionProvider.
private static DriverManagerConnectionProviderImpl buildConnectionProvider(Properties props, final boolean allowAggressiveRelease) {
DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl() {
public boolean supportsAggressiveRelease() {
return allowAggressiveRelease;
}
};
connectionProvider.configure(props);
return connectionProvider;
}
use of org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl in project hibernate-orm by hibernate.
the class JtaAwareConnectionProviderImpl method configure.
@Override
public void configure(Map configurationValues) {
Properties connectionSettings = new Properties();
transferSetting(Environment.DRIVER, configurationValues, connectionSettings);
transferSetting(Environment.URL, configurationValues, connectionSettings);
transferSetting(Environment.USER, configurationValues, connectionSettings);
transferSetting(Environment.PASS, configurationValues, connectionSettings);
transferSetting(Environment.ISOLATION, configurationValues, connectionSettings);
Properties passThroughSettings = ConnectionProviderInitiator.getConnectionProperties(configurationValues);
if (passThroughSettings != null) {
for (String setting : passThroughSettings.stringPropertyNames()) {
transferSetting(Environment.CONNECTION_PREFIX + '.' + setting, configurationValues, connectionSettings);
}
}
connectionSettings.setProperty(Environment.AUTOCOMMIT, "false");
delegate = new DriverManagerConnectionProviderImpl();
delegate.configure(connectionSettings);
}
use of org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl in project hibernate-orm by hibernate.
the class AbstractMultiTenancyTest method registerConnectionProvider.
// tag::multitenacy-hibernate-MultiTenantConnectionProvider-example[]
protected void registerConnectionProvider(String tenantIdentifier) {
Properties properties = properties();
properties.put(Environment.URL, tenantUrl(properties.getProperty(Environment.URL), tenantIdentifier));
DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl();
connectionProvider.configure(properties);
connectionProviderMap.put(tenantIdentifier, connectionProvider);
}
use of org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl in project tutorials by eugenp.
the class SchemaMultiTenantConnectionProvider method initConnectionProvider.
private ConnectionProvider initConnectionProvider() throws IOException {
Properties properties = new Properties();
properties.load(getClass().getResourceAsStream("/hibernate-schema-multitenancy.properties"));
DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl();
connectionProvider.configure(properties);
return connectionProvider;
}
Aggregations