ComponentMap<> not working ?
Hello,
i am trying to map a component by following the example on http://wiki.fluentnhibernate.org/Fluent_mapping#Components under ComponentMap<>
But it keeps throwing an FluentNHibernate.Visitors.UnresolvedComponentReferenceVisitedException ("Visitor attempted on unresolved componented reference 'Password', referenced from property 'Password' of 'Member', unable to continue").
I Just have a PasswordMap class which inherits from ComponentMap and contains the Component Mappings and then i map it with Component(x => x.Password);
If i use the "old" way of mapping components it works fine.
I am using Build #629.
Anyone have an idea of what I could be doing wrong ?
Martin
Btw. when mapping with Component(x => x.TheComponent) it only exposes a ColumnPrefix method, it is missing the possibility to set Access, LazyLoad and so on (which is possible when you use the "old" way of mapping a component).
Support Staff 2 Posted by James Gregory on 17 Mar, 2010 10:27 AM
The
ComponentMap
functionality is still experimental, as you've discovered. I'd appreciate it if you could post a minimal solution to reproduce the issue, and I'll look into it. I've not had any issues usingComponentMap
, so you must be doing something differently to how I am.3 Posted by Martin on 17 Mar, 2010 02:59 PM
Thanks for the reply.
my PasswordMap class looks like the following
My MemberMap class contains the following (please notice it is a SubClassMap)
If i map the "old" way it works fine, but using the ComponentMap it fails when creating the Session factory.
Support Staff 4 Posted by James Gregory on 17 Mar, 2010 03:01 PM
Great, thanks. I'll investigate it asap.
It may be a conflict with SubclassMap, as I've not personally used the two
together. Any chance you could run a test and see if you get the same
behaviour from within a ClassMap?
5 Posted by Martin on 17 Mar, 2010 03:17 PM
Thanks for the quick reply.
Will try it out in a moment.
Actually first really thought about it might be the problem when writting the reply :)
6 Posted by Martin on 17 Mar, 2010 03:35 PM
Just tested it.
It only throws an exception when using the SubclassMap, so I would assume it has something to do with that. :)
Support Staff 7 Posted by James Gregory on 17 Mar, 2010 03:38 PM
Great, well that makes my life a little easier. Thanks Martin, I'll look
into this when I get home.
8 Posted by Martin on 25 Mar, 2010 02:28 PM
Got home yet ? ;)
Any idea of when you will merge Pauls latest changes/commits ? :)
Also the source code downloaded from fluentnhibernate.org is missing the file "CombinedAssemblyTypeSource.cs" (which of course can easily be downloaded via GIT, but i thought it would be nice to mention it).
9 Posted by Daniel Tian on 14 Apr, 2010 04:23 AM
Any update on this issue? I just ran into the same problem, where I have a SubclassMap and a Component inside it. I'm using the latest revision as of 4/13/2010.
Support Staff 10 Posted by James Gregory on 30 Apr, 2010 08:37 AM
If you try updating now there have been some bug fixes made on
ComponentMap
andSubclassMap
use.11 Posted by Daniel Tian on 01 May, 2010 01:36 AM
Thanks James, the most recent trunk head solved the subclass mapping issue, but now I'm running into a new problem. One of my components contains another component:
Both
Agency
andAddress
are components. In another entity class, I have aPrimaryAgency
and aBackupAgency
. I'm using automapping, and I expect to see these rows in the database table for the entity:Instead I get:
So it looks like it's picking up the column name from the root
Agency
component, but not for theAddress
component inside (it's mapping both addresses to the same column). When I try to save an instance of the entity, it throws anArgumentOutOfRangeException
, which makes me believe that Fluent's trying to look for the correct column name but can't find it since it was mapped wrong.Does this problem have anything to do with the commit message you wrote about nested-same-type components? I thought that meant that you can't nest an
Agency
inside anAgency
, for example, but something like anAddress
inside anAgency
should be fine.12 Posted by Daniel Tian on 01 May, 2010 02:24 AM
Also, the most recent build seems to have broke fluent component mapping so that this doesn't work anymore:
but this still does:
It will throw a NullReferenceException when trying to build the
Configuration
object. Reverting back a previous version of Fluent NHib shows that this bug was introduced with the fixes to components in subclasses.Support Staff 13 Posted by James Gregory on 06 May, 2010 08:27 PM
I've just committed some fixes that should hopefully stop you getting a NullReferenceException. Any updates would be helpful, if you get time to check out the new version.
14 Posted by Daniel Tian on 06 May, 2010 10:30 PM
Hi James, thanks for the update. Because I switched over to using HBM mappings, I haven't had a chance to test whether the component mapping fails for fluent mappings. However, the issue I mentioned in post #11 with components inside components mapping incorrectly still exists for automapping. Also, overriding the mapping for a component throws a
FluentConfigurationException
: "Tried to add a component 'Agency' when already added".This is the code I'm using:
15 Posted by Daniel Tian on 06 May, 2010 10:39 PM
Ok, I just checked the fluent mappings with an older revision of my project. Seems like the NullReferenceException problem is fixed.
Support Staff 16 Posted by James Gregory on 07 May, 2010 08:05 AM
Just curious, did you test your automapper setup with the latest binary? I did make a fix for another support issue, #128, which was related to the automapper and the "already added" exception.
17 Posted by Daniel Tian on 07 May, 2010 08:12 AM
I tested it with commit 12cc9f81a9fa31fdde47, which was the latest commit at the time of my previous post (gotta hate how there's no revision numbers). I noticed that the latest commit currently is the one where component overriding is fixed. I'll try it out later and let you know if it's been fixed.
Support Staff 18 Posted by James Gregory on 07 May, 2010 08:18 AM
Yeah, there's one commit after 12cc9f8, and that's the one with the fix for the "already added" exception.