Search in sources :

Example 16 with SchemaCreatorImpl

use of org.hibernate.tool.schema.internal.SchemaCreatorImpl in project hibernate-orm by hibernate.

the class IndexTest method verifyIndexCreated.

private void verifyIndexCreated(String mappingResource, String expectedIndexName) {
    final Metadata metadata = new MetadataSources(ssr).addResource(mappingResource).buildMetadata();
    final JournalingSchemaToolingTarget target = new JournalingSchemaToolingTarget();
    new SchemaCreatorImpl(ssr).doCreation(metadata, false, target);
    assertTrue("Expected index [" + expectedIndexName + "] not seen in schema creation output", target.containedText(expectedIndexName));
}
Also used : SchemaCreatorImpl(org.hibernate.tool.schema.internal.SchemaCreatorImpl) Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources)

Example 17 with SchemaCreatorImpl

use of org.hibernate.tool.schema.internal.SchemaCreatorImpl 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);
    }
}
Also used : DdlTransactionIsolatorTestingImpl(org.hibernate.test.util.DdlTransactionIsolatorTestingImpl) SchemaCreatorImpl(org.hibernate.tool.schema.internal.SchemaCreatorImpl) SchemaDropperImpl(org.hibernate.tool.schema.internal.SchemaDropperImpl) HibernateException(org.hibernate.HibernateException) Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources) SchemaValidator(org.hibernate.tool.hbm2ddl.SchemaValidator) GenerationTarget(org.hibernate.tool.schema.internal.exec.GenerationTarget) GenerationTargetToDatabase(org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase) ConnectionProvider(org.hibernate.engine.jdbc.connections.spi.ConnectionProvider) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 18 with SchemaCreatorImpl

use of org.hibernate.tool.schema.internal.SchemaCreatorImpl in project hibernate-orm by hibernate.

the class ImplicitCompositeKeyJoinTest method testSchemaCreationSQLCommandIsGeneratedWithTheCorrectColumnSizeValues.

@Test
public void testSchemaCreationSQLCommandIsGeneratedWithTheCorrectColumnSizeValues() throws Exception {
    final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
    try {
        final org.hibernate.boot.Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(Employee.class).buildMetadata();
        boolean createTableEmployeeFound = false;
        final List<String> commands = new SchemaCreatorImpl(ssr).generateCreationCommands(metadata, false);
        for (String command : commands) {
            LOGGER.info(command);
            if (command.toLowerCase().contains("create table employee")) {
                final String[] columnsDefinition = getColumnsDefinition(command);
                for (int i = 0; i < columnsDefinition.length; i++) {
                    checkColumnSize(columnsDefinition[i]);
                }
                createTableEmployeeFound = true;
            }
        }
        assertTrue("Expected create table command for Employee entity not found", createTableEmployeeFound);
    } finally {
        StandardServiceRegistryBuilder.destroy(ssr);
    }
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) MetadataSources(org.hibernate.boot.MetadataSources) SchemaCreatorImpl(org.hibernate.tool.schema.internal.SchemaCreatorImpl) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) Test(org.junit.Test)

Aggregations

SchemaCreatorImpl (org.hibernate.tool.schema.internal.SchemaCreatorImpl)18 MetadataSources (org.hibernate.boot.MetadataSources)14 Metadata (org.hibernate.boot.Metadata)11 Test (org.junit.Test)9 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)7 DdlTransactionIsolatorTestingImpl (org.hibernate.test.util.DdlTransactionIsolatorTestingImpl)6 SchemaDropperImpl (org.hibernate.tool.schema.internal.SchemaDropperImpl)6 GenerationTargetToDatabase (org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase)6 HashMap (java.util.HashMap)4 TestForIssue (org.hibernate.testing.TestForIssue)4 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)3 ServiceRegistryImplementor (org.hibernate.service.spi.ServiceRegistryImplementor)3 JournalingSchemaToolingTarget (org.hibernate.test.hbm.index.JournalingSchemaToolingTarget)3 Map (java.util.Map)2 SessionFactoryBuilder (org.hibernate.boot.SessionFactoryBuilder)2 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)2 DriverManagerConnectionProviderImpl (org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl)2 JdbcConnectionAccessImpl (org.hibernate.testing.boot.JdbcConnectionAccessImpl)2 HibernateSchemaManagementTool (org.hibernate.tool.schema.internal.HibernateSchemaManagementTool)2 SchemaManagementException (org.hibernate.tool.schema.spi.SchemaManagementException)2