HasMany Component map with child-Components
Hope someone can help me with this. I want to map a list of value objects (as Components) that contain a value object:
I want to use the HasMany syntax like so:
HasMany(x => x.Favorites)
.Access.CamelCaseField(Prefix.Underscore)
.Cascade.SaveUpdate()
.AsList()
.Component(c => c.Favorite); // what I'd like to do... :)
// where Favorite is mapped via a ComponentMap<Favorite>, I don't think that this is supported, correct?
There are two issues:
a) I want to reuse the ComponentMaps I've already created
b) even if the above syntax isn't supported, Favorite has a child component, so I'm not sure how I would map it using standard HasMany component mapping.
Is there any way to accomplish this mapping? Any help is greatly appreciated!
2 Posted by Peter F. on 18 Jun, 2010 09:07 PM
I've also tried:
But get XML validation error: The required attribute 'name' is missing.
Thanks!
Support Staff 3 Posted by Paul Batum on 19 Jun, 2010 07:43 AM
Are you running on the 1.1 release? I think there were some recent fixes for
this area of functionality.
4 Posted by Peter F. on 19 Jun, 2010 02:08 PM
Yes, I'm running 1.1.
Support Staff 5 Posted by James Gregory on 19 Jun, 2010 02:20 PM
Using ComponentMap with collections currently isn't supported. I
wanted 1.1 to have it, but we ran out of time. It's high on the
priority list.
Sent from my jelly bone
6 Posted by Peter F. on 19 Jun, 2010 03:57 PM
Oh well. Any thoughts on a workaround? I would think my second example (not using ComponentMap in collection, but rather in the inner-mapping) would be ok, since it seems like the regular Component API.
What do you think is involved to support this in the trunk? Is it close but not RTM, or is it a ways off?
7 Posted by Jacob Madsen on 22 Jun, 2010 07:29 AM
Is there no workaround?
8 Posted by Peter F. on 22 Jun, 2010 12:49 PM
Jacob, the workaround I've chosen it simply to map this with hbm for now.
9 Posted by Jacob Madsen on 23 Jun, 2010 07:14 AM
Ok, bummer :-)
Can I see the hbm?
Support Staff 10 Posted by Paul Batum on 27 Jun, 2010 09:22 AM
Hi Peter,
Your second approach should work, it turns out this issue was fixed but just
post our 1.1 release. I'm waiting for James to merge the change in to the
trunk but in the meantime you can get it from my dev branch which is here:
http://github.com/paulbatum/fluent-nhibernate/tree/dev
Sorry it took me so long to realise!
11 Posted by Peter F. on 28 Jun, 2010 02:20 PM
That's awesome, Paul. Is your dev branch relatively stable? Thanks!
Support Staff 12 Posted by Paul Batum on 28 Jun, 2010 11:27 PM
Peter, James merged my changes into the official trunk last night so there's
no need to grab it from my dev branch anymore.
13 Posted by Peter F. on 29 Jun, 2010 11:35 AM
You guys rock. Thanks again!
14 Posted by cremor on 05 Nov, 2010 10:20 AM
Any news on ComponentMaps in collections or as CompositeElement?
Support Staff 15 Posted by James Gregory on 05 Nov, 2010 10:24 AM
Still not supported, sadly.