HHH-10802 - Add test for issue
This commit is contained in:
parent
9c29ec22c5
commit
b76f8c2065
|
@ -19,10 +19,12 @@ 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.boot.spi.MetadataImplementor;
|
import org.hibernate.boot.spi.MetadataImplementor;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
import org.hibernate.engine.config.spi.ConfigurationService;
|
||||||
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||||
|
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
|
||||||
import org.hibernate.tool.schema.SourceType;
|
import org.hibernate.tool.schema.SourceType;
|
||||||
import org.hibernate.tool.schema.TargetType;
|
import org.hibernate.tool.schema.TargetType;
|
||||||
import org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl;
|
import org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl;
|
||||||
|
@ -61,7 +63,8 @@ public class CrossSchemaForeignKeyGenerationTest extends BaseUnitTestCase {
|
||||||
public void setUp() throws IOException {
|
public void setUp() throws IOException {
|
||||||
output = File.createTempFile( "update_script", ".sql" );
|
output = File.createTempFile( "update_script", ".sql" );
|
||||||
output.deleteOnExit();
|
output.deleteOnExit();
|
||||||
ssr = new StandardServiceRegistryBuilder().build();
|
ssr = new StandardServiceRegistryBuilder().applySetting( AvailableSettings.HBM2DLL_CREATE_SCHEMAS, "true" )
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
@ -92,6 +95,32 @@ public class CrossSchemaForeignKeyGenerationTest extends BaseUnitTestCase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestForIssue(jiraKey = "HHH-10802")
|
||||||
|
public void testSchemaUpdateDoesNotFailResolvingCrossSchemaForeignKey() throws Exception {
|
||||||
|
final MetadataSources metadataSources = new MetadataSources( ssr );
|
||||||
|
metadataSources.addAnnotatedClass( SchemaOneEntity.class );
|
||||||
|
metadataSources.addAnnotatedClass( SchemaTwoEntity.class );
|
||||||
|
|
||||||
|
MetadataImplementor metadata = (MetadataImplementor) metadataSources.buildMetadata();
|
||||||
|
metadata.validate();
|
||||||
|
|
||||||
|
new SchemaExport()
|
||||||
|
.setOutputFile( output.getAbsolutePath() )
|
||||||
|
.setFormat( false )
|
||||||
|
.create( EnumSet.of( TargetType.DATABASE ), metadata );
|
||||||
|
|
||||||
|
new SchemaUpdate().setHaltOnError( true )
|
||||||
|
.setOutputFile( output.getAbsolutePath() )
|
||||||
|
.setFormat( false )
|
||||||
|
.execute( EnumSet.of( TargetType.DATABASE ), metadata );
|
||||||
|
|
||||||
|
new SchemaExport().setHaltOnError( true )
|
||||||
|
.setOutputFile( output.getAbsolutePath() )
|
||||||
|
.setFormat( false )
|
||||||
|
.drop( EnumSet.of( TargetType.DATABASE ), metadata );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-10420")
|
@TestForIssue(jiraKey = "HHH-10420")
|
||||||
public void testSchemaMigrationForeignKeysAreGeneratedAfterAllTheTablesAreCreated() throws Exception {
|
public void testSchemaMigrationForeignKeysAreGeneratedAfterAllTheTablesAreCreated() throws Exception {
|
||||||
|
@ -178,6 +207,4 @@ public class CrossSchemaForeignKeyGenerationTest extends BaseUnitTestCase {
|
||||||
new TargetDatabaseImpl( ssr.getService( JdbcServices.class ).getBootstrapJdbcConnectionAccess() )
|
new TargetDatabaseImpl( ssr.getService( JdbcServices.class ).getBootstrapJdbcConnectionAccess() )
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue