diff --git a/src/NServiceBus.NHibernate.Tests/ApprovalFiles/DDL.MySaga.approved.txt b/src/NServiceBus.NHibernate.Tests/ApprovalFiles/DDL.Sagas_MsSql2012.approved.txt similarity index 100% rename from src/NServiceBus.NHibernate.Tests/ApprovalFiles/DDL.MySaga.approved.txt rename to src/NServiceBus.NHibernate.Tests/ApprovalFiles/DDL.Sagas_MsSql2012.approved.txt diff --git a/src/NServiceBus.NHibernate.Tests/ApprovalFiles/DDL.Sagas_Oracle10g.approved.txt b/src/NServiceBus.NHibernate.Tests/ApprovalFiles/DDL.Sagas_Oracle10g.approved.txt new file mode 100644 index 000000000..795e53030 --- /dev/null +++ b/src/NServiceBus.NHibernate.Tests/ApprovalFiles/DDL.Sagas_Oracle10g.approved.txt @@ -0,0 +1,42 @@ + + + drop table MySaga_CollectionEntry cascade constraints + + drop table MySaga cascade constraints + + drop table EntriesWithoutId cascade constraints + + create table MySaga_CollectionEntry ( + Id RAW(16) not null, + Value NUMBER(19,5), + SagaData_id RAW(16), + primary key (Id) + ) + + create table MySaga ( + Id RAW(16) not null, + Originator VARCHAR2(255), + OriginalMessageId VARCHAR2(255), + UniqueId VARCHAR2(255) unique, + primary key (Id) + ) + + create table EntriesWithoutId ( + SagaData_id RAW(16) not null, + Value1 NUMBER(19,5), + Value2 NUMBER(19,5) + ) + + create index IDX236CFC11C9055018 on MySaga_CollectionEntry (SagaData_id) + + alter table MySaga_CollectionEntry + add constraint FK236CFC11C9055018 + foreign key (SagaData_id) + references MySaga + + create index IDX7519A193C9055018 on EntriesWithoutId (SagaData_id) + + alter table EntriesWithoutId + add constraint FK7519A193C9055018 + foreign key (SagaData_id) + references MySaga \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.Tests/GenerateScriptsTest.cs b/src/NServiceBus.NHibernate.Tests/GenerateScriptsTest.cs index ab7c6b07b..10749d6b2 100644 --- a/src/NServiceBus.NHibernate.Tests/GenerateScriptsTest.cs +++ b/src/NServiceBus.NHibernate.Tests/GenerateScriptsTest.cs @@ -50,11 +50,19 @@ public void GatewayDeduplication() // This test is ignored for .NETCore because of the unstable foreign key name generation in NHibernate https://github.com/nhibernate/nhibernate-core/issues/1769 [Test] [MethodImpl(MethodImplOptions.NoInlining)] - public void MySaga() + public void Sagas_MsSql2012() { var script = ScriptGenerator.GenerateSagaScript(); Approver.Verify(script); } + + [Test] + [MethodImpl(MethodImplOptions.NoInlining)] + public void Sagas_Oracle10g() + { + var script = ScriptGenerator.GenerateSagaScript(); + Approver.Verify(script); + } #endif } diff --git a/src/NServiceBus.NHibernate/SagaPersisters/SagaModelMapper.cs b/src/NServiceBus.NHibernate/SagaPersisters/SagaModelMapper.cs index 90d25b23e..5aff695f0 100644 --- a/src/NServiceBus.NHibernate/SagaPersisters/SagaModelMapper.cs +++ b/src/NServiceBus.NHibernate/SagaPersisters/SagaModelMapper.cs @@ -59,6 +59,7 @@ public static void AddMappings(Configuration configuration, SagaMetadataCollecti foreach (var collection in mappings.IterateCollections) { var table = collection.CollectionTable; + foreach (var foreignKey in table.ForeignKeyIterator) { var idx = new Index();