Search in sources :

Example 11 with BootstrapServiceRegistry

use of org.hibernate.boot.registry.BootstrapServiceRegistry in project hibernate-orm by hibernate.

the class CollectionJoinTableNamingTest method testCollectionJoinTableNamingLegacyJpaStrategy.

@Test
@TestForIssue(jiraKey = "HHH-9908")
public void testCollectionJoinTableNamingLegacyJpaStrategy() {
    final MetadataSources metadataSources = new MetadataSources();
    try {
        metadataSources.addAnnotatedClass(Input.class);
        metadataSources.addAnnotatedClass(Ptx.class);
        final Metadata metadata = metadataSources.getMetadataBuilder().applyImplicitNamingStrategy(ImplicitNamingStrategyLegacyJpaImpl.INSTANCE).build();
        assertSameTableUsed(metadata);
    } finally {
        ServiceRegistry metaServiceRegistry = metadataSources.getServiceRegistry();
        if (metaServiceRegistry instanceof BootstrapServiceRegistry) {
            BootstrapServiceRegistryBuilder.destroy(metaServiceRegistry);
        }
    }
}
Also used : MetadataSources(org.hibernate.boot.MetadataSources) Metadata(org.hibernate.boot.Metadata) BootstrapServiceRegistry(org.hibernate.boot.registry.BootstrapServiceRegistry) ServiceRegistry(org.hibernate.service.ServiceRegistry) BootstrapServiceRegistry(org.hibernate.boot.registry.BootstrapServiceRegistry) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 12 with BootstrapServiceRegistry

use of org.hibernate.boot.registry.BootstrapServiceRegistry in project hibernate-orm by hibernate.

the class BaseNamingTests method doTest.

@Test
public void doTest() {
    final MetadataSources metadataSources = new MetadataSources();
    try {
        applySources(metadataSources);
        final Metadata metadata = metadataSources.getMetadataBuilder().applyImplicitNamingStrategy(getImplicitNamingStrategyToUse()).build();
        validateCustomer(metadata);
        validateOrder(metadata);
        validateZipCode(metadata);
        validateCustomerRegisteredTrademarks(metadata);
        validateCustomerAddresses(metadata);
        validateCustomerOrders(metadata);
        validateCustomerIndustries(metadata);
    } finally {
        ServiceRegistry metaServiceRegistry = metadataSources.getServiceRegistry();
        if (metaServiceRegistry instanceof BootstrapServiceRegistry) {
            BootstrapServiceRegistryBuilder.destroy(metaServiceRegistry);
        }
    }
}
Also used : MetadataSources(org.hibernate.boot.MetadataSources) Metadata(org.hibernate.boot.Metadata) BootstrapServiceRegistry(org.hibernate.boot.registry.BootstrapServiceRegistry) ServiceRegistry(org.hibernate.service.ServiceRegistry) BootstrapServiceRegistry(org.hibernate.boot.registry.BootstrapServiceRegistry) Test(org.junit.Test)

Example 13 with BootstrapServiceRegistry

use of org.hibernate.boot.registry.BootstrapServiceRegistry in project hibernate-orm by hibernate.

the class SpreadNaturalIdTest method testSpreadNaturalIdDeclarationGivesMappingException.

@Test
@SuppressWarnings("EmptyCatchBlock")
public void testSpreadNaturalIdDeclarationGivesMappingException() {
    final MetadataSources metadataSources = new MetadataSources().addAnnotatedClass(Principal.class).addAnnotatedClass(User.class);
    try {
        metadataSources.buildMetadata();
        fail("Expected binders to throw an exception");
    } catch (AnnotationException expected) {
    } finally {
        ServiceRegistry metaServiceRegistry = metadataSources.getServiceRegistry();
        if (metaServiceRegistry instanceof BootstrapServiceRegistry) {
            BootstrapServiceRegistryBuilder.destroy(metaServiceRegistry);
        }
    }
}
Also used : MetadataSources(org.hibernate.boot.MetadataSources) AnnotationException(org.hibernate.AnnotationException) BootstrapServiceRegistry(org.hibernate.boot.registry.BootstrapServiceRegistry) ServiceRegistry(org.hibernate.service.ServiceRegistry) BootstrapServiceRegistry(org.hibernate.boot.registry.BootstrapServiceRegistry) Test(org.junit.Test)

Example 14 with BootstrapServiceRegistry

use of org.hibernate.boot.registry.BootstrapServiceRegistry in project hibernate-orm by hibernate.

the class BaseNonConfigCoreFunctionalTestCase method constructStandardServiceRegistryBuilder.

protected final StandardServiceRegistryBuilder constructStandardServiceRegistryBuilder() {
    final BootstrapServiceRegistryBuilder bsrb = new BootstrapServiceRegistryBuilder();
    // by default we do not share the BootstrapServiceRegistry nor the StandardServiceRegistry,
    // so we want the BootstrapServiceRegistry to be automatically closed when the
    // StandardServiceRegistry is closed.
    bsrb.enableAutoClose();
    configureBootstrapServiceRegistryBuilder(bsrb);
    final BootstrapServiceRegistry bsr = bsrb.build();
    afterBootstrapServiceRegistryBuilt(bsr);
    final Map settings = new HashMap();
    addSettings(settings);
    final StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder(bsr);
    initialize(ssrb);
    ssrb.applySettings(settings);
    configureStandardServiceRegistryBuilder(ssrb);
    return ssrb;
}
Also used : BootstrapServiceRegistryBuilder(org.hibernate.boot.registry.BootstrapServiceRegistryBuilder) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) HashMap(java.util.HashMap) BootstrapServiceRegistry(org.hibernate.boot.registry.BootstrapServiceRegistry) HashMap(java.util.HashMap) Map(java.util.Map)

Example 15 with BootstrapServiceRegistry

use of org.hibernate.boot.registry.BootstrapServiceRegistry in project hibernate-orm by hibernate.

the class SchemaExport method buildStandardServiceRegistry.

private static StandardServiceRegistry buildStandardServiceRegistry(CommandLineArgs commandLineArgs) throws Exception {
    final BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().build();
    final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder(bsr);
    if (commandLineArgs.cfgXmlFile != null) {
        ssrBuilder.configure(commandLineArgs.cfgXmlFile);
    }
    Properties properties = new Properties();
    if (commandLineArgs.propertiesFile != null) {
        properties.load(new FileInputStream(commandLineArgs.propertiesFile));
    }
    ssrBuilder.applySettings(properties);
    return ssrBuilder.build();
}
Also used : BootstrapServiceRegistryBuilder(org.hibernate.boot.registry.BootstrapServiceRegistryBuilder) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Properties(java.util.Properties) BootstrapServiceRegistry(org.hibernate.boot.registry.BootstrapServiceRegistry) FileInputStream(java.io.FileInputStream)

Aggregations

BootstrapServiceRegistry (org.hibernate.boot.registry.BootstrapServiceRegistry)26 Test (org.junit.Test)18 MetadataSources (org.hibernate.boot.MetadataSources)16 ServiceRegistry (org.hibernate.service.ServiceRegistry)14 BootstrapServiceRegistryBuilder (org.hibernate.boot.registry.BootstrapServiceRegistryBuilder)11 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)11 Metadata (org.hibernate.boot.Metadata)5 MappingException (org.hibernate.MappingException)4 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)4 TestForIssue (org.hibernate.testing.TestForIssue)4 FileInputStream (java.io.FileInputStream)3 Properties (java.util.Properties)3 AnnotationException (org.hibernate.AnnotationException)3 File (java.io.File)2 MetadataBuilder (org.hibernate.boot.MetadataBuilder)2 Configuration (org.hibernate.cfg.Configuration)2 Integrator (org.hibernate.integrator.spi.Integrator)2 InputStream (java.io.InputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 HashMap (java.util.HashMap)1