Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NH-3380 - One-To-Many of Union-Subclass saves to wrong table #1297

Open
nhibernate-bot opened this issue Oct 12, 2017 · 0 comments
Open

NH-3380 - One-To-Many of Union-Subclass saves to wrong table #1297

nhibernate-bot opened this issue Oct 12, 2017 · 0 comments

Comments

@nhibernate-bot
Copy link
Collaborator

Zoltan Juhasz created an issue — 17th January 2013, 11:07:06:

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


Zoltan Juhasz added a comment — 26th February 2013, 8:31:40:

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.


Zoltan Juhasz added a comment — 5th September 2013, 11:50:12:

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 measureGroupsystemId = @p0, measureGroup_deviceId = @p1, measureGroupid = @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 measureGroupsystemId = @p0, measureGroup_deviceId = @p1, measureGroupid = @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 :(
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


Daniel A. Schilling added a comment — 12th November 2013, 18:20:42:

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 added a comment — 12th November 2013, 22:19:34:

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.


Zoltan Juhasz added a comment — 16th November 2013, 7:06:41:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants