Search in sources :

Example 46 with MetadataSources

use of org.hibernate.boot.MetadataSources in project hibernate-orm by hibernate.

the class CollectionPkTest method verifyPkNameUsed.

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

Example 47 with MetadataSources

use of org.hibernate.boot.MetadataSources in project hibernate-orm by hibernate.

the class DisabledForeignKeyTest method expandedTests.

@Test
@TestForIssue(jiraKey = "HHH-9704")
public void expandedTests() {
    StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder();
    StandardServiceRegistry standardRegistry = registryBuilder.build();
    try {
        final MetadataSources sources = new MetadataSources(standardRegistry);
        sources.addAnnotatedClass(ManyToManyOwner.class);
        sources.addAnnotatedClass(ManyToManyTarget.class);
        final MetadataImplementor metadata = (MetadataImplementor) sources.buildMetadata();
        metadata.validate();
        // export the schema
        new SchemaExport().execute(EnumSet.of(TargetType.DATABASE), SchemaExport.Action.BOTH, metadata);
        try {
            // update the schema
            new SchemaUpdate().execute(EnumSet.of(TargetType.DATABASE), metadata);
        } finally {
            // drop the schema
            new SchemaExport().execute(EnumSet.of(TargetType.DATABASE), SchemaExport.Action.DROP, metadata);
        }
    } finally {
        StandardServiceRegistryBuilder.destroy(standardRegistry);
    }
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) MetadataSources(org.hibernate.boot.MetadataSources) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) SchemaUpdate(org.hibernate.tool.hbm2ddl.SchemaUpdate) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 48 with MetadataSources

use of org.hibernate.boot.MetadataSources in project hibernate-orm by hibernate.

the class ExtendsTest method testAllSeparateInOne.

@Test
public void testAllSeparateInOne() {
    Metadata metadata = new MetadataSources(serviceRegistry).addResource(getBaseForMappings() + "extendshbm/allseparateinone.hbm.xml").buildMetadata();
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Customer"));
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Person"));
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Employee"));
}
Also used : Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources) Test(org.junit.Test)

Example 49 with MetadataSources

use of org.hibernate.boot.MetadataSources in project hibernate-orm by hibernate.

the class ExtendsTest method testOutOfOrder.

@Test
public void testOutOfOrder() {
    Metadata metadata = new MetadataSources(serviceRegistry).addResource(getBaseForMappings() + "extendshbm/Customer.hbm.xml").addResource(getBaseForMappings() + "extendshbm/Person.hbm.xml").addResource(getBaseForMappings() + "extendshbm/Employee.hbm.xml").buildMetadata();
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Customer"));
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Person"));
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Employee"));
}
Also used : Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources) Test(org.junit.Test)

Example 50 with MetadataSources

use of org.hibernate.boot.MetadataSources in project hibernate-orm by hibernate.

the class ExtendsTest method testAllInOne.

@Test
public void testAllInOne() {
    Metadata metadata = new MetadataSources(serviceRegistry).addResource(getBaseForMappings() + "extendshbm/allinone.hbm.xml").buildMetadata();
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Customer"));
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Person"));
    assertNotNull(metadata.getEntityBinding("org.hibernate.test.extendshbm.Employee"));
}
Also used : Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources) Test(org.junit.Test)

Aggregations

MetadataSources (org.hibernate.boot.MetadataSources)293 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)193 Test (org.junit.Test)192 Metadata (org.hibernate.boot.Metadata)123 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)120 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)76 TestForIssue (org.hibernate.testing.TestForIssue)57 PersistentClass (org.hibernate.mapping.PersistentClass)53 SchemaExport (org.hibernate.tool.hbm2ddl.SchemaExport)41 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)37 Before (org.junit.Before)33 BootstrapServiceRegistry (org.hibernate.boot.registry.BootstrapServiceRegistry)30 ServiceRegistry (org.hibernate.service.ServiceRegistry)26 RootClass (org.hibernate.mapping.RootClass)25 HashMap (java.util.HashMap)20 SimpleValue (org.hibernate.mapping.SimpleValue)20 SchemaUpdate (org.hibernate.tool.hbm2ddl.SchemaUpdate)20 File (java.io.File)19 Property (org.hibernate.mapping.Property)18 Map (java.util.Map)17