Multiple instances of a nested componet in the same entity map to the same database fields.
I’m using the “subclass” strategy, which uses a single table for an inheritance hierarchy. There is a component of type XX which contains a nested component of type YY. The superclass contains an instance of XX called xx1. A subclass adds a second instance of type XX called xx2. FNH automapping maps the properties of YY to the same database columns for both instances. (I use the AutoMapping Setup option to define XX and YY as component types.)
To overcome this problem, I used an override on the superclass to add a prefix to the columns mapped from xx1. I get the error “Tried to add component ‘xx1’ when already added.”
Next I tried adding a ComponentMap based fluent mapping to define the component XX mapping. Same error.
Then I removed the AutoMapping Setup option that defined type XX as a component, but I retained the fluent mapping added above. This time I get the error “Unable to find external component for ‘XX’, referenced from property ‘xx1’ of ‘Superclass’.”
Any ideas on how to get this to work in FNH without having to add a custom-tailored HbmMapping?
Thanks in advance!
Comments are currently closed for this discussion. You can start a new one.
2 Posted by Daniel Tian on 01 May, 2010 02:56 AM
I've just encountered the same issue. See my post here:
http://support.fluentnhibernate.org/discussions/help/44-componentma...
I tried the same workaround and ran into the same problem.
Support Staff 3 Posted by James Gregory on 16 May, 2010 05:27 PM
There have been many fixes lately relating to automapping, and ComponentMap too, I would suggest you try the latest version and see if your problem persists.
4 Posted by MylesRip on 20 May, 2010 06:01 PM
Build 1.0.0.680 solves this problem by using an improved mapping routine that doesn't map the fields of both instances to the same database column. Thanks for the fix!
James Gregory closed this discussion on 20 May, 2010 07:45 PM.