Fixes for NH-3480 and NH-3453 #211
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
http://nhibernate.jira.com/browse/NH-3453
Hello, all.
This is my first attempt at a proposed contribution to NHibernate, so please be patient with me. I have created proposed fixes for JIRA issues NH-3480 and NH-3453 related to one-to-many and many-to-one mappings using property references.
Basically, the problem with both of these issues is that in some parts of NHibernate, the values used to join entities together is assumed to be the keys of the entities, and "forgets" that those values could be property reference values instead. For both of these issues, the property values were attempted to be used as the entity key for the purposes of determining if an entity was dirty and for finding the owner of the collection from the first-level cache. In my proposed solution, I attempted to make a distinction between these two values so that one would not be used in place of the other.
The one thing I has to do to make this work was make significant changes to the one-to-many join walker and persister. In order to get the actual ID of the collection's owning entity into the dataset read from the database so owner could then be gotten from the first-level cache, I decided to join in the owning entity's table and return its ID when retrieving the collection when a property reference was used. This seemed to be the best solution to this problem.
Although I have been using NHibernate for a couple of years and have dug into the code many times during that time, but this is the deepest I have dug into it, much less attempted to made changes, so I am open to suggestions or pointers to things I have missed.
Thank you for you attention.