use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.
the class JoinColumnOverrideTest method testBlownPrecision.
@Test
@TestForIssue(jiraKey = "ANN-748")
public void testBlownPrecision() throws Exception {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().applySetting(AvailableSettings.DIALECT, "SQLServer").build();
try {
Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(Bunny.class).addAnnotatedClass(PointyTooth.class).addAnnotatedClass(TwinkleToes.class).buildMetadata();
boolean foundPointyToothCreate = false;
boolean foundTwinkleToesCreate = false;
List<String> commands = new SchemaCreatorImpl(ssr).generateCreationCommands(metadata, false);
for (String command : commands) {
log.debug(command);
if (expectedSqlPointyTooth.equals(command)) {
foundPointyToothCreate = true;
} else if (expectedSqlTwinkleToes.equals(command)) {
foundTwinkleToesCreate = true;
}
}
assertTrue("Expected create table command for PointyTooth entity not found", foundPointyToothCreate);
assertTrue("Expected create table command for TwinkleToes entity not found", foundTwinkleToesCreate);
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.
the class DiscriminatorOptionsTest method testPropertyBasedDiscriminatorForcing.
@Test
public void testPropertyBasedDiscriminatorForcing() throws Exception {
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(BaseClass2.class).addAnnotatedClass(SubClass2.class).getMetadataBuilder().enableImplicitForcingOfDiscriminatorsInSelect(true).build();
PersistentClass persistentClass = metadata.getEntityBinding(BaseClass2.class.getName());
assertNotNull(persistentClass);
assertTrue(persistentClass instanceof RootClass);
RootClass root = (RootClass) persistentClass;
assertTrue("Discriminator should be forced by property", root.isForceDiscriminator());
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.
the class DuplicatedDiscriminatorValueTest method tryBuildingSessionFactory.
private void tryBuildingSessionFactory(Class... annotatedClasses) {
final StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build();
try {
final MetadataSources metadataSources = new MetadataSources(serviceRegistry);
for (Class annotatedClass : annotatedClasses) {
metadataSources.addAnnotatedClass(annotatedClass);
}
final Metadata metadata = metadataSources.buildMetadata();
final SessionFactory sessionFactory = metadata.buildSessionFactory();
sessionFactory.close();
} finally {
StandardServiceRegistryBuilder.destroy(serviceRegistry);
}
}
use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.
the class CfgXmlParsingTest method testCfgXmlWithBadNamespaceAndSchemaLocation.
@Test(expected = ConfigurationException.class)
public void testCfgXmlWithBadNamespaceAndSchemaLocation() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().configure("org/hibernate/test/boot/cfgXml/badnamespace.cfg.xml").build();
StandardServiceRegistryBuilder.destroy(ssr);
fail("Expecting the bad namespace to fail");
}
use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.
the class CfgXmlResourceNameClosingTest method testStreamClosing.
@Test
public void testStreamClosing() {
BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().applyClassLoaderService(classLoaderService).build();
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder(bsr).configure("org/hibernate/test/boot/cfgXml/hibernate.cfg.xml").build();
try {
for (InputStreamWrapper openedStream : classLoaderService.openedStreams) {
assertTrue(openedStream.wasClosed);
}
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
assertTrue(classLoaderService.stopped);
}
Aggregations