HHH-9948 - SequenceStyleGenerator uses potentially incorrect name for table/sequence in DML statements
This commit is contained in:
parent
7bc37fd2f3
commit
cfd5414321
|
@ -9,6 +9,8 @@ package org.hibernate.id.enhanced;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
|
import org.hibernate.boot.internal.MetadataBuilderImpl;
|
||||||
|
import org.hibernate.boot.model.relational.Database;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
@ -17,8 +19,8 @@ import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.id.PersistentIdentifierGenerator;
|
import org.hibernate.id.PersistentIdentifierGenerator;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
|
||||||
import org.hibernate.testing.boot.MetadataBuildingContextTestingImpl;
|
import org.hibernate.testing.boot.MetadataBuildingContextTestingImpl;
|
||||||
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.hibernate.testing.junit4.ExtraAssertions.assertClassAssignability;
|
import static org.hibernate.testing.junit4.ExtraAssertions.assertClassAssignability;
|
||||||
|
@ -45,6 +47,10 @@ public class SequenceStyleConfigUnitTest extends BaseUnitTestCase {
|
||||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||||
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
||||||
|
|
||||||
|
generator.registerExportables(
|
||||||
|
new Database( new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry ) )
|
||||||
|
);
|
||||||
|
|
||||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||||
assertClassAssignability( NoopOptimizer.class, generator.getOptimizer().getClass() );
|
assertClassAssignability( NoopOptimizer.class, generator.getOptimizer().getClass() );
|
||||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||||
|
@ -77,6 +83,10 @@ public class SequenceStyleConfigUnitTest extends BaseUnitTestCase {
|
||||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||||
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
||||||
|
|
||||||
|
generator.registerExportables(
|
||||||
|
new Database( new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry ) )
|
||||||
|
);
|
||||||
|
|
||||||
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
||||||
assertClassAssignability( NoopOptimizer.class, generator.getOptimizer().getClass() );
|
assertClassAssignability( NoopOptimizer.class, generator.getOptimizer().getClass() );
|
||||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||||
|
@ -104,6 +114,11 @@ public class SequenceStyleConfigUnitTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||||
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
||||||
|
|
||||||
|
generator.registerExportables(
|
||||||
|
new Database( new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry ) )
|
||||||
|
);
|
||||||
|
|
||||||
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
||||||
assertClassAssignability( PooledOptimizer.class, generator.getOptimizer().getClass() );
|
assertClassAssignability( PooledOptimizer.class, generator.getOptimizer().getClass() );
|
||||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||||
|
@ -123,6 +138,10 @@ public class SequenceStyleConfigUnitTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||||
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
||||||
|
generator.registerExportables(
|
||||||
|
new Database( new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry ) )
|
||||||
|
);
|
||||||
|
|
||||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||||
assertClassAssignability( PooledOptimizer.class, generator.getOptimizer().getClass() );
|
assertClassAssignability( PooledOptimizer.class, generator.getOptimizer().getClass() );
|
||||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||||
|
@ -149,6 +168,10 @@ public class SequenceStyleConfigUnitTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||||
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
||||||
|
generator.registerExportables(
|
||||||
|
new Database( new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry ) )
|
||||||
|
);
|
||||||
|
|
||||||
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
||||||
assertClassAssignability( PooledOptimizer.class, generator.getOptimizer().getClass() );
|
assertClassAssignability( PooledOptimizer.class, generator.getOptimizer().getClass() );
|
||||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||||
|
@ -173,6 +196,10 @@ public class SequenceStyleConfigUnitTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||||
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
||||||
|
generator.registerExportables(
|
||||||
|
new Database( new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry ) )
|
||||||
|
);
|
||||||
|
|
||||||
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
||||||
assertClassAssignability( NoopOptimizer.class, generator.getOptimizer().getClass() );
|
assertClassAssignability( NoopOptimizer.class, generator.getOptimizer().getClass() );
|
||||||
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
|
||||||
|
@ -198,6 +225,10 @@ public class SequenceStyleConfigUnitTest extends BaseUnitTestCase {
|
||||||
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
|
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
|
||||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||||
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
||||||
|
generator.registerExportables(
|
||||||
|
new Database( new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry ) )
|
||||||
|
);
|
||||||
|
|
||||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||||
assertClassAssignability( NoopOptimizer.class, generator.getOptimizer().getClass() );
|
assertClassAssignability( NoopOptimizer.class, generator.getOptimizer().getClass() );
|
||||||
assertEquals( 1, generator.getOptimizer().getIncrementSize() );
|
assertEquals( 1, generator.getOptimizer().getIncrementSize() );
|
||||||
|
@ -209,6 +240,9 @@ public class SequenceStyleConfigUnitTest extends BaseUnitTestCase {
|
||||||
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
|
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
|
||||||
generator = new SequenceStyleGenerator();
|
generator = new SequenceStyleGenerator();
|
||||||
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
||||||
|
generator.registerExportables(
|
||||||
|
new Database( new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry ) )
|
||||||
|
);
|
||||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||||
assertClassAssignability( HiLoOptimizer.class, generator.getOptimizer().getClass() );
|
assertClassAssignability( HiLoOptimizer.class, generator.getOptimizer().getClass() );
|
||||||
assertEquals( 20, generator.getOptimizer().getIncrementSize() );
|
assertEquals( 20, generator.getOptimizer().getIncrementSize() );
|
||||||
|
@ -220,6 +254,9 @@ public class SequenceStyleConfigUnitTest extends BaseUnitTestCase {
|
||||||
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
|
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
|
||||||
generator = new SequenceStyleGenerator();
|
generator = new SequenceStyleGenerator();
|
||||||
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
||||||
|
generator.registerExportables(
|
||||||
|
new Database( new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry ) )
|
||||||
|
);
|
||||||
// because the dialect reports to not support pooled seqyences, the expectation is that we will
|
// because the dialect reports to not support pooled seqyences, the expectation is that we will
|
||||||
// use a table for the backing structure...
|
// use a table for the backing structure...
|
||||||
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
|
||||||
|
@ -243,12 +280,18 @@ public class SequenceStyleConfigUnitTest extends BaseUnitTestCase {
|
||||||
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
|
props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
|
||||||
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
SequenceStyleGenerator generator = new SequenceStyleGenerator();
|
||||||
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
||||||
|
generator.registerExportables(
|
||||||
|
new Database( new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry ) )
|
||||||
|
);
|
||||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||||
assertClassAssignability( PooledOptimizer.class, generator.getOptimizer().getClass() );
|
assertClassAssignability( PooledOptimizer.class, generator.getOptimizer().getClass() );
|
||||||
|
|
||||||
props.setProperty( Environment.PREFER_POOLED_VALUES_LO, "true" );
|
props.setProperty( Environment.PREFER_POOLED_VALUES_LO, "true" );
|
||||||
generator = new SequenceStyleGenerator();
|
generator = new SequenceStyleGenerator();
|
||||||
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
generator.configure( StandardBasicTypes.LONG, props, serviceRegistry );
|
||||||
|
generator.registerExportables(
|
||||||
|
new Database( new MetadataBuilderImpl.MetadataBuildingOptionsImpl( serviceRegistry ) )
|
||||||
|
);
|
||||||
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
|
||||||
assertClassAssignability( PooledLoOptimizer.class, generator.getOptimizer().getClass() );
|
assertClassAssignability( PooledLoOptimizer.class, generator.getOptimizer().getClass() );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue