use of org.hibernate.tool.hbm2ddl.SchemaValidator in project hibernate-orm by hibernate.
the class JoinTableWithDefaultSchemaTest method testGetTableDataForJoinTableWithDefaultSchema.
@Test
@TestForIssue(jiraKey = "HHH-10978")
@RequiresDialect(SQLServerDialect.class)
public void testGetTableDataForJoinTableWithDefaultSchema() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().applySetting(AvailableSettings.DEFAULT_CATALOG, "hibernate_orm_test").applySetting(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "false").build();
try {
final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(ssr).addAnnotatedClass(Task.class).addAnnotatedClass(Project.class).buildMetadata();
metadata.validate();
// first create the schema...
new SchemaExport().create(EnumSet.of(TargetType.DATABASE), metadata);
try {
// validate the schema
new SchemaValidator().validate(metadata);
} finally {
// cleanup
new SchemaExport().drop(EnumSet.of(TargetType.DATABASE), metadata);
}
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.tool.hbm2ddl.SchemaValidator in project hibernate-orm by hibernate.
the class SynonymValidationTest method testSynonymUsingIndividuallySchemaValidator.
@Test
public void testSynonymUsingIndividuallySchemaValidator() {
ssr = new StandardServiceRegistryBuilder().applySetting(AvailableSettings.ENABLE_SYNONYMS, "true").applySetting(AvailableSettings.HBM2DDL_JDBC_METADATA_EXTRACTOR_STRATEGY, JdbcMetadaAccessStrategy.INDIVIDUALLY).build();
try {
final MetadataSources metadataSources = new MetadataSources(ssr);
metadataSources.addAnnotatedClass(TestEntityWithSynonym.class);
metadataSources.addAnnotatedClass(TestEntity.class);
new SchemaValidator().validate(metadataSources.buildMetadata());
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.tool.hbm2ddl.SchemaValidator in project hibernate-orm by hibernate.
the class ConnectionsReleaseTest method testSchemaValidatorReleasesAllConnections.
@Test
public void testSchemaValidatorReleasesAllConnections() throws SQLException {
new SchemaValidator().validate(metadata);
assertThat(connectionProvider.getOpenConnection(), is(0));
}
use of org.hibernate.tool.hbm2ddl.SchemaValidator in project hibernate-orm by hibernate.
the class SynonymValidationTest method testSynonymUsingGroupedSchemaValidator.
@Test
@TestForIssue(jiraKey = "HHH-12406")
public void testSynonymUsingGroupedSchemaValidator() {
// Hibernate should use JdbcMetadaAccessStrategy.INDIVIDUALLY when
// AvailableSettings.ENABLE_SYNONYMS is true,
// even if JdbcMetadaAccessStrategy.GROUPED is specified.
ssr = new StandardServiceRegistryBuilder().applySetting(AvailableSettings.ENABLE_SYNONYMS, "true").applySetting(AvailableSettings.HBM2DDL_JDBC_METADATA_EXTRACTOR_STRATEGY, JdbcMetadaAccessStrategy.GROUPED).build();
try {
final MetadataSources metadataSources = new MetadataSources(ssr);
metadataSources.addAnnotatedClass(TestEntityWithSynonym.class);
metadataSources.addAnnotatedClass(TestEntity.class);
new SchemaValidator().validate(metadataSources.buildMetadata());
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.tool.hbm2ddl.SchemaValidator in project hibernate-orm by hibernate.
the class TableGeneratorQuotingTest method testTableGeneratorQuoting.
@Test
@TestForIssue(jiraKey = "HHH-7927")
public void testTableGeneratorQuoting() {
final Metadata metadata = new MetadataSources(serviceRegistry).addAnnotatedClass(TestEntity.class).buildMetadata();
final ConnectionProvider connectionProvider = serviceRegistry.getService(ConnectionProvider.class);
final GenerationTarget target = new GenerationTargetToDatabase(new DdlTransactionIsolatorTestingImpl(serviceRegistry, new JdbcEnvironmentInitiator.ConnectionProviderJdbcConnectionAccess(connectionProvider)));
new SchemaCreatorImpl(serviceRegistry).doCreation(metadata, false, target);
try {
new SchemaValidator().validate(metadata);
} catch (HibernateException e) {
fail("The identifier generator table should have validated. " + e.getMessage());
} finally {
new SchemaDropperImpl(serviceRegistry).doDrop(metadata, false, target);
}
}
Aggregations