Search in sources :

Example 1 with MultipleHiLoPerTableGenerator

use of org.hibernate.id.MultipleHiLoPerTableGenerator in project hibernate-orm by hibernate.

the class Db2GenerationTest method testLegacyGeneratorTableCreationOnDb2.

@Test
@TestForIssue(jiraKey = "HHH-9850")
public void testLegacyGeneratorTableCreationOnDb2() {
    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());
        MultipleHiLoPerTableGenerator generator = new MultipleHiLoPerTableGenerator();
        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);
    }
}
Also used : MultipleHiLoPerTableGenerator(org.hibernate.id.MultipleHiLoPerTableGenerator) Table(org.hibernate.mapping.Table) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources) Properties(java.util.Properties) DB2Dialect(org.hibernate.dialect.DB2Dialect) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Aggregations

Properties (java.util.Properties)1 Metadata (org.hibernate.boot.Metadata)1 MetadataSources (org.hibernate.boot.MetadataSources)1 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)1 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)1 DB2Dialect (org.hibernate.dialect.DB2Dialect)1 MultipleHiLoPerTableGenerator (org.hibernate.id.MultipleHiLoPerTableGenerator)1 Table (org.hibernate.mapping.Table)1 TestForIssue (org.hibernate.testing.TestForIssue)1 Test (org.junit.Test)1