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);
}
}
}
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);
}
}
}
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);
}
}
}
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;
}
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();
}
Aggregations