use of org.hibernate.service.ServiceRegistry in project hibernate-orm by hibernate.
the class CollectionJoinTableNamingTest method testCollectionJoinTableNamingJpaCompliantStrategy.
@Test
@TestForIssue(jiraKey = "HHH-9908")
public void testCollectionJoinTableNamingJpaCompliantStrategy() {
// Even in 4.3, with JPA compliant naming, Hibernate creates an unusable table...
final MetadataSources metadataSources = new MetadataSources();
try {
metadataSources.addAnnotatedClass(Input.class);
metadataSources.addAnnotatedClass(Ptx.class);
final Metadata metadata = metadataSources.getMetadataBuilder().applyImplicitNamingStrategy(ImplicitNamingStrategyJpaCompliantImpl.INSTANCE).build();
assertSameTableUsed(metadata);
} finally {
ServiceRegistry metaServiceRegistry = metadataSources.getServiceRegistry();
if (metaServiceRegistry instanceof BootstrapServiceRegistry) {
BootstrapServiceRegistryBuilder.destroy(metaServiceRegistry);
}
}
}
use of org.hibernate.service.ServiceRegistry 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.service.ServiceRegistry 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.service.ServiceRegistry 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.service.ServiceRegistry in project hibernate-orm by hibernate.
the class IdentifierHelperTest method testAutoQuotingDisabled.
@Test
public void testAutoQuotingDisabled() {
ServiceRegistry sr = ServiceRegistryTestingImpl.forUnitTesting(Collections.singletonMap(AvailableSettings.KEYWORD_AUTO_QUOTING_ENABLED, // true is the default, but to be sure...
true));
Identifier identifier = sr.getService(JdbcEnvironment.class).getIdentifierHelper().toIdentifier("select");
assertTrue(identifier.isQuoted());
StandardServiceRegistryBuilder.destroy(sr);
sr = ServiceRegistryTestingImpl.forUnitTesting(Collections.singletonMap(AvailableSettings.KEYWORD_AUTO_QUOTING_ENABLED, false));
identifier = sr.getService(JdbcEnvironment.class).getIdentifierHelper().toIdentifier("select");
assertFalse(identifier.isQuoted());
StandardServiceRegistryBuilder.destroy(sr);
}
Aggregations