-
Notifications
You must be signed in to change notification settings - Fork 934
System.Reflection.TargetException when an interface is used as class mapping proxy definition #2043
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
Milestone
Comments
bahusoid
added a commit
to bahusoid/nhibernate-core
that referenced
this issue
Mar 8, 2019
This was referenced Mar 8, 2019
Regression of 5.0. |
fredericDelaporte
pushed a commit
that referenced
this issue
Mar 18, 2019
fredericDelaporte
pushed a commit
to fredericDelaporte/nhibernate-core
that referenced
this issue
Mar 18, 2019
fredericDelaporte
pushed a commit
to fredericDelaporte/nhibernate-core
that referenced
this issue
Mar 19, 2019
This was referenced Mar 19, 2019
Back-ported to 5.1.5 and 5.0.7. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
as u may know, we are currently updating from an old NHibernate 4 (4.0.3) version to the current NHibernate 5 (5.2.3) version and are facing some issues.
We often declare an interface as class proxy, as it is stated in the Mapping Documetation.
With NHibernate 5 a System.Reflection.TargetException is thrown now, when a Many-To-One reference is updated with a proxy object. I first thought, that this only happens in case of union-subclass-mappings (cause we often used proxy definitions in inheritance mappings), but this isn't the case. It is independ from inheritance mappings. Let me explain.
This is an example model:
This is the model where it is referenced:
I've deactivated the reflection optimization to better debug this problem:
The exception was triggerd from the flush after the update and is thrown here:
This makes of course sense, because:
As you can see, the given entity parameter doesn't inherit from the "EntityWithInterfaceProxyDefinition" class, which is the parent class of the idGetter. So you get an TargetException by invoking the idGetter.
I guess this fix raised this issue:
I've attached some test mapping classes, as well as a test fixture with two tests to reproduce this problem. The test "UpdateEntityWithInterfaceLookup" fails the other one doesn't fail (cause it uses the clsas itself as proxy)
I know removing the proxy definition should be the workaround for this issue. But as long you don't say, we are doing something completly wrong, i would rather avoid that.
Thx, in adavance.
TargetExceptionTest.zip
The text was updated successfully, but these errors were encountered: