use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.
the class Db2GenerationTest method testNewGeneratorTableCreationOnDb2.
@Test
@TestForIssue(jiraKey = "HHH-9850")
public void testNewGeneratorTableCreationOnDb2() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().applySetting(AvailableSettings.DIALECT, DB2Dialect.class.getName()).build();
try {
Metadata metadata = new MetadataSources(ssr).buildMetadata();
assertEquals(0, metadata.getDatabase().getDefaultNamespace().getTables().size());
TableGenerator generator = new TableGenerator();
Properties properties = new Properties();
generator.configure(IntegerType.INSTANCE, properties, ssr);
generator.registerExportables(metadata.getDatabase());
assertEquals(1, metadata.getDatabase().getDefaultNamespace().getTables().size());
final Table table = metadata.getDatabase().getDefaultNamespace().getTables().iterator().next();
final String[] createCommands = new DB2Dialect().getTableExporter().getSqlCreateStrings(table, metadata);
assertContains("sequence_name varchar(255) not null", createCommands[0]);
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.
the class UUIDBasedIdInterpretationTest method testBinaryRuntimeUsage.
@Test
@TestForIssue(jiraKey = "HHH-10564")
@RequiresDialect(H2Dialect.class)
public void testBinaryRuntimeUsage() {
StandardServiceRegistry ssr = buildStandardServiceRegistry(H2Dialect.class, true);
try {
final Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(UuidIdEntity.class).buildMetadata();
final SessionFactory sf = metadata.buildSessionFactory();
try {
Session s = sf.openSession();
try {
s.beginTransaction();
s.byId(UuidIdEntity.class).load(UUID.randomUUID());
s.getTransaction().commit();
} finally {
s.close();
}
} finally {
sf.close();
}
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.
the class NoDatabaseMetaDataTest method testNoJdbcMetadataDefaultDialect.
@Test
@TestForIssue(jiraKey = "HHH-10515")
public void testNoJdbcMetadataDefaultDialect() {
final StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySetting("hibernate.temp.use_jdbc_metadata_defaults", "false").build();
JdbcEnvironment jdbcEnvironment = serviceRegistry.getService(JdbcEnvironment.class);
ExtractedDatabaseMetaData extractedDatabaseMetaData = jdbcEnvironment.getExtractedDatabaseMetaData();
assertNull(extractedDatabaseMetaData.getConnectionCatalogName());
assertNull(extractedDatabaseMetaData.getConnectionSchemaName());
assertTrue(extractedDatabaseMetaData.getTypeInfoSet().isEmpty());
assertTrue(extractedDatabaseMetaData.getExtraKeywords().isEmpty());
assertFalse(extractedDatabaseMetaData.supportsNamedParameters());
assertFalse(extractedDatabaseMetaData.supportsRefCursors());
assertFalse(extractedDatabaseMetaData.supportsScrollableResults());
assertFalse(extractedDatabaseMetaData.supportsGetGeneratedKeys());
assertFalse(extractedDatabaseMetaData.supportsBatchUpdates());
assertFalse(extractedDatabaseMetaData.supportsDataDefinitionInTransaction());
assertFalse(extractedDatabaseMetaData.doesDataDefinitionCauseTransactionCommit());
assertNull(extractedDatabaseMetaData.getSqlStateType());
assertFalse(extractedDatabaseMetaData.doesLobLocatorUpdateCopy());
StandardServiceRegistryBuilder.destroy(serviceRegistry);
}
use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.
the class Tests method testJpaJoinColumnPhysicalNaming.
@Test
@TestForIssue(jiraKey = "HHH-9961")
public void testJpaJoinColumnPhysicalNaming() {
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().applySettings(Environment.getProperties()).build();
try {
final MetadataSources metadataSources = new MetadataSources(ssr);
metadataSources.addAnnotatedClass(Language.class);
final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder();
metadataBuilder.applyImplicitNamingStrategy(ImplicitNamingStrategyJpaCompliantImpl.INSTANCE);
metadataBuilder.applyPhysicalNamingStrategy(PhysicalNamingStrategyImpl.INSTANCE);
final Metadata metadata = metadataBuilder.build();
((MetadataImplementor) metadata).validate();
final PersistentClass languageBinding = metadata.getEntityBinding(Language.class.getName());
final Property property = languageBinding.getProperty("fallBack");
Iterator itr = property.getValue().getColumnIterator();
assertTrue(itr.hasNext());
final Column column = (Column) itr.next();
assertFalse(itr.hasNext());
assertEquals("C_FALLBACK_ID", column.getName().toUpperCase(Locale.ROOT));
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.
the class SimpleNationalizedTest method simpleNationalizedTest.
@Test
public void simpleNationalizedTest() {
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
final MetadataSources ms = new MetadataSources(ssr);
ms.addAnnotatedClass(NationalizedEntity.class);
final Metadata metadata = ms.buildMetadata();
PersistentClass pc = metadata.getEntityBinding(NationalizedEntity.class.getName());
assertNotNull(pc);
Property prop = pc.getProperty("nvarcharAtt");
if (metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect) {
// See issue HHH-10693
assertSame(StringType.INSTANCE, prop.getType());
} else {
assertSame(StringNVarcharType.INSTANCE, prop.getType());
}
prop = pc.getProperty("materializedNclobAtt");
if (metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect) {
// See issue HHH-10693
assertSame(MaterializedClobType.INSTANCE, prop.getType());
} else {
assertSame(MaterializedNClobType.INSTANCE, prop.getType());
}
prop = pc.getProperty("nclobAtt");
assertSame(NClobType.INSTANCE, prop.getType());
prop = pc.getProperty("nlongvarcharcharAtt");
assertSame(NTextType.INSTANCE, prop.getType());
prop = pc.getProperty("ncharArrAtt");
if (metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect) {
// See issue HHH-10693
assertSame(CharacterArrayType.INSTANCE, prop.getType());
} else {
assertSame(StringNVarcharType.INSTANCE, prop.getType());
}
prop = pc.getProperty("ncharacterAtt");
if (metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect) {
// See issue HHH-10693
assertSame(CharacterType.INSTANCE, prop.getType());
} else {
assertSame(CharacterNCharType.INSTANCE, prop.getType());
}
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
Aggregations