One-To-Many of Union-Subclass saves to wrong table

Description

Unable to save One-To-Many with Many-To-One relations. See attachments for more info. There is a README.TXT file with the details and a completed test projects for reproduce the issue.

Preject in the zip file created with NuGet, but as you wish I removed DLLs from the zip file.

Test project is a simple Visual Studio 2010 project. Requirements:
Iesi.Collections 3.2.0.4000
log4net 2.0.0 [1.2.11]
NHibernate 3.3.2.4000
NHibernate Mapping Attributes 3.2.0.0

Environment

None

Attachments

1
  • 17 Jan 2013, 11:07 AM

Activity

Show:

Zoltan Juhasz November 16, 2013 at 7:06 AM

Unfortunatelly the "marked set with inverse" is a good workaround and it solves my problem. Thanks!

Zoltan Juhasz November 12, 2013 at 10:19 PM

I think it is a question of a viewpoint. I have several types of union-subclass relations. All types working fine, except this situation. NHibernate forgets to check inherited entities of the "Measure" entity type, so it failed to make the association between the owner of the set and the "set entity". This issue exists in a One-To-Many with Many-To-One entity relation scenario.

Daniel A. Schilling November 12, 2013 at 6:20 PM

I think the title of this issue might not be accurate enough. union-subclass looks like the most important part of your issue - the problem boils down to the `Measures` table being updated instead of the `Currencies` table. union-subclass is the part of your mapping that specifies which table these two entities should go in. I think "One-To-Many of Union-Subclass saves to wrong table" would be a better title.

Also, MeasureGroup.measures should be marked inverse.

Zoltan Juhasz September 5, 2013 at 11:50 AM

The exception:

2013-09-05 13:47:33,786 DEBUG [Agent: adapter run thread for test 'TestDemoBug' with id 'a769cf8d-dc3d-408c-b384-51c510aaf050'] [NHibernate.SQL] - Batch commands:
command 0:UPDATE Measures SET measureGroup_systemId = @p0, measureGroup_deviceId = @p1, measureGroup_id = @p2 WHERE systemId = @p3 AND deviceId = @p4 AND id = @p5;@p0 = 1 [Type: Int64 (0)], @p1 = 1 [Type: Int64 (0)], @p2 = 781670897921 [Type: Int64 (0)], @p3 = 1 [Type: Int64 (0)], @p4 = 2 [Type: Int64 (0)], @p5 = 781671005783 [Type: Int64 (0)]
command 1:UPDATE Measures SET measureGroup_systemId = @p0, measureGroup_deviceId = @p1, measureGroup_id = @p2 WHERE systemId = @p3 AND deviceId = @p4 AND id = @p5;@p0 = 1 [Type: Int64 (0)], @p1 = 1 [Type: Int64 (0)], @p2 = 781670897921 [Type: Int64 (0)], @p3 = 1 [Type: Int64 (0)], @p4 = 3 [Type: Int64 (0)], @p5 = 781671019530 [Type: Int64 (0)]

2013-09-05 13:47:33,816 DEBUG [Agent: adapter run thread for test 'TestDemoBug' with id 'a769cf8d-dc3d-408c-b384-51c510aaf050'] [NHibernate.AdoNet.AbstractBatcher] - Closed IDbCommand, open IDbCommands: 0
2013-09-05 13:47:33,816 ERROR [Agent: adapter run thread for test 'TestDemoBug' with id 'a769cf8d-dc3d-408c-b384-51c510aaf050'] [NHibernate.Event.Default.AbstractFlushingEventListener] - Could not synchronize database state with session
NHibernate.StaleStateException: Batch update returned unexpected row count from update; actual row count: 0; expected: 2
at NHibernate.AdoNet.Expectations.VerifyOutcomeBatched(Int32 expectedRowCount, Int32 rowCount)
at NHibernate.AdoNet.SqlClientBatchingBatcher.DoExecuteBatch(IDbCommand ps)
at NHibernate.AdoNet.AbstractBatcher.ExecuteBatchWithTiming(IDbCommand ps)
at NHibernate.AdoNet.AbstractBatcher.ExecuteBatch()
at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
at NHibernate.Engine.ActionQueue.ExecuteActions()
at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session)
2013-09-05 13:47:33,861 DEBUG [Agent: adapter run thread for test 'TestDemoBug' with id 'a769cf8d-dc3d-408c-b384-51c510aaf050'] [NHibernate.AdoNet.ConnectionManager] - registering flush end
2013-09-05 13:47:33,861 ERROR [Agent: adapter run thread for test 'TestDemoBug' with id 'a769cf8d-dc3d-408c-b384-51c510aaf050'] [NHibernate.Test.DemoBugUnitTest] - The bug still exists disappointed face
NHibernate.StaleStateException: Batch update returned unexpected row count from update; actual row count: 0; expected: 2
at NHibernate.AdoNet.Expectations.VerifyOutcomeBatched(Int32 expectedRowCount, Int32 rowCount)
at NHibernate.AdoNet.SqlClientBatchingBatcher.DoExecuteBatch(IDbCommand ps)
at NHibernate.AdoNet.AbstractBatcher.ExecuteBatchWithTiming(IDbCommand ps)
at NHibernate.AdoNet.AbstractBatcher.ExecuteBatch()
at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
at NHibernate.Engine.ActionQueue.ExecuteActions()
at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session)
at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event)
at NHibernate.Impl.SessionImpl.Flush()
at NHibernate.Transaction.AdoTransaction.Commit()
at NHibernate.Test.DemoBugUnitTest.TestDemoBug() in C:\Development\NET\HVS\Forge\Research\NHibernate.BugTest\NHibernate.Test\DemoBugUnitTest.cs:line 110

Zoltan Juhasz February 26, 2013 at 8:31 AM

Any comment for this issue? This is a very critical issue, NHibernate becomes unusable with this bug... My opinion, this is very important to fix.

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created January 17, 2013 at 11:07 AM
Updated December 2, 2014 at 10:45 AM
Who's Looking?