Search in sources :

Example 51 with SchemaExport

use of org.hibernate.tool.hbm2ddl.SchemaExport in project hibernate-orm by hibernate.

the class TestFkUpdating method setUp.

@Before
public void setUp() {
    serviceRegistry = new StandardServiceRegistryBuilder().build();
    metadata = (MetadataImplementor) new MetadataSources(serviceRegistry).addAnnotatedClass(User.class).addAnnotatedClass(Role.class).buildMetadata();
    System.out.println("********* Starting SchemaExport for START-UP *************************");
    new SchemaExport().create(EnumSet.of(TargetType.DATABASE, TargetType.STDOUT), metadata);
    System.out.println("********* Completed SchemaExport for START-UP *************************");
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) MetadataSources(org.hibernate.boot.MetadataSources) SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport) Before(org.junit.Before)

Example 52 with SchemaExport

use of org.hibernate.tool.hbm2ddl.SchemaExport in project hibernate-orm by hibernate.

the class JoinedInheritanceForeignKeyTest method createSchema.

private void createSchema(Class[] annotatedClasses) {
    final MetadataSources metadataSources = new MetadataSources(ssr);
    for (Class c : annotatedClasses) {
        metadataSources.addAnnotatedClass(c);
    }
    metadata = (MetadataImplementor) metadataSources.buildMetadata();
    metadata.validate();
    new SchemaExport().setHaltOnError(true).setOutputFile(output.getAbsolutePath()).setFormat(false).create(EnumSet.of(TargetType.SCRIPT), metadata);
}
Also used : MetadataSources(org.hibernate.boot.MetadataSources) SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport)

Example 53 with SchemaExport

use of org.hibernate.tool.hbm2ddl.SchemaExport in project hibernate-orm by hibernate.

the class CrossSchemaForeignKeyGenerationTest method testSchemaUpdateDoesNotFailResolvingCrossSchemaForeignKey.

@Test
@TestForIssue(jiraKey = "HHH-10802")
public void testSchemaUpdateDoesNotFailResolvingCrossSchemaForeignKey() throws Exception {
    final MetadataSources metadataSources = new MetadataSources(ssr);
    metadataSources.addAnnotatedClass(SchemaOneEntity.class);
    metadataSources.addAnnotatedClass(SchemaTwoEntity.class);
    MetadataImplementor metadata = (MetadataImplementor) metadataSources.buildMetadata();
    metadata.validate();
    new SchemaExport().setOutputFile(output.getAbsolutePath()).setFormat(false).create(EnumSet.of(TargetType.DATABASE), metadata);
    new SchemaUpdate().setHaltOnError(true).setOutputFile(output.getAbsolutePath()).setFormat(false).execute(EnumSet.of(TargetType.DATABASE), metadata);
    new SchemaExport().setHaltOnError(true).setOutputFile(output.getAbsolutePath()).setFormat(false).drop(EnumSet.of(TargetType.DATABASE), metadata);
}
Also used : MetadataSources(org.hibernate.boot.MetadataSources) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) SchemaUpdate(org.hibernate.tool.hbm2ddl.SchemaUpdate) SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 54 with SchemaExport

use of org.hibernate.tool.hbm2ddl.SchemaExport in project hibernate-orm by hibernate.

the class SchemaExportWithGlobalQuotingEnabledTest method tearDown.

@After
public void tearDown() {
    System.out.println("********* Starting SchemaExport (drop) for TEAR-DOWN *************************");
    new SchemaExport().drop(EnumSet.of(TargetType.STDOUT, TargetType.DATABASE), metadata);
    System.out.println("********* Completed SchemaExport (drop) for TEAR-DOWN *************************");
    StandardServiceRegistryBuilder.destroy(serviceRegistry);
    serviceRegistry = null;
}
Also used : SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport) After(org.junit.After)

Example 55 with SchemaExport

use of org.hibernate.tool.hbm2ddl.SchemaExport in project hibernate-orm by hibernate.

the class SchemaExportWithIndexAndDefaultSchema method shouldCreateIndex.

@Test
public void shouldCreateIndex() {
    SchemaExport schemaExport = new SchemaExport();
    schemaExport.create(EnumSet.of(TargetType.DATABASE, TargetType.STDOUT), metadata);
    assertThat(schemaExport.getExceptions().size(), is(0));
}
Also used : SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport) Test(org.junit.Test)

Aggregations

SchemaExport (org.hibernate.tool.hbm2ddl.SchemaExport)90 Test (org.junit.Test)45 MetadataSources (org.hibernate.boot.MetadataSources)42 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)28 ISchemaExport (org.jboss.tools.hibernate.runtime.spi.ISchemaExport)27 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)22 TestForIssue (org.hibernate.testing.TestForIssue)13 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)12 Configuration (org.hibernate.cfg.Configuration)12 Connection (java.sql.Connection)10 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)10 After (org.junit.After)10 SchemaUpdate (org.hibernate.tool.hbm2ddl.SchemaUpdate)9 File (java.io.File)8 Before (org.junit.Before)8 HashMap (java.util.HashMap)5 Metadata (org.hibernate.boot.Metadata)5 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)5 SQLException (java.sql.SQLException)4 Entity (javax.persistence.Entity)4