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

Automapper: union-subtree not propagating through class hierarchy #334

Merged
merged 2 commits into from
Sep 18, 2020

Conversation

jcpreston26
Copy link
Contributor

I am converting a project from using ClassMaps to using the AutoMapper in order to simplify the existing project and any future changes. One class inheritance tree in the project is built using UnionSubclassMapping and when attempting to build the NH configuration using the automapper, the following error is thrown:

NHibernate.MappingException: (XmlDocument)(267,8): XML validation error: The element 'union-subclass' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'joined-subclass' in namespace 'urn:nhibernate-mapping-2.2'. List of possible elements expected: 'property, many-to-one, one-to-one, component, dynamic-component, properties, any, map, set, list, bag, idbag, array, primitive-array, union-subclass, loader, sql-insert, sql-update, sql-delete, results
et, query, sql-query' in namespace 'urn:nhibernate-mapping-2.2'.

This inheritance tree has three layers. The AutoMapper was not carrying the knowledge that union-subtree was to be used down to the grandchild object, which caused it to switch and start using joined-subtree, which is not allowed.

I have assembled a patch and a test for checking the issue. I don't know if a similar issue exists for other subclassing strategies. I can also confirm that the patched version of Fluent works with my project and it is now generating correct HBM files.

…apper, check the subclasstype to see if it should be a union-subclass
@chester89
Copy link
Collaborator

What version of NHibernate did you use to test that?

@jcpreston26
Copy link
Contributor Author

I saw the same behavior when using both NH 4.0.0.4000 and NH 4.0.4.4000.

I also just went back and tested it with Fluent 1.4 and NH 3.3.1 and had the same exception thrown.

@chester89
Copy link
Collaborator

I see. Let me try that and I think I can make a bugfix release in January

среда, 6 января 2016 г. пользователь Jared Preston написал:

I saw the same behavior when using both NH 4.0.0.4000 and NH 4.0.4.4000.

I also just went back and tested it with Fluent 1.4 and NH 3.3.1 and had
the same exception thrown.


Reply to this email directly or view it on GitHub
#334 (comment)
.

Yours faithfully,
Gleb

@hazzik
Copy link
Member

hazzik commented Sep 18, 2020

Looks legit. I've run tests locally.

@hazzik hazzik merged commit 4f1759f into nhibernate:master Sep 18, 2020
@hazzik hazzik added the bug label Sep 18, 2020
@hazzik hazzik added this to the 2.1.3 milestone Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants