HasMany Component map with child-Components

Peter F.'s Avatar

Peter F.

18 Jun, 2010 08:56 PM via web

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!

  1. 2 Posted by Peter F. on 18 Jun, 2010 09:07 PM

    Peter F.'s Avatar

    I've also tried:

    HasMany(x => x.Favorites)
                .Table("BOOKMARK")
                .KeyColumn("USERID")
                .Access.CamelCaseField(Prefix.Underscore)
                .Cascade.SaveUpdate()
                .AsList()
                .Component(favorite =>
                               {
                                   favorite.Component(z => z.SccId, m => m.Map(v => v.Value));
                                   favorite.Map(m => m.EntityName);
                                   favorite.Map(m => m.EntityStatus);
                               });
    

    But get XML validation error: The required attribute 'name' is missing.

    Thanks!

  2. Support Staff 3 Posted by Paul Batum on 19 Jun, 2010 07:43 AM

    Paul Batum's Avatar

    Are you running on the 1.1 release? I think there were some recent fixes for
    this area of functionality.

  3. 4 Posted by Peter F. on 19 Jun, 2010 02:08 PM

    Peter F.'s Avatar

    Yes, I'm running 1.1.

  4. Support Staff 5 Posted by James Gregory on 19 Jun, 2010 02:20 PM

    James Gregory's Avatar

    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

  5. 6 Posted by Peter F. on 19 Jun, 2010 03:57 PM

    Peter F.'s Avatar

    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?

  6. 7 Posted by Jacob Madsen on 22 Jun, 2010 07:29 AM

    Jacob Madsen's Avatar

    Is there no workaround?

  7. 8 Posted by Peter F. on 22 Jun, 2010 12:49 PM

    Peter F.'s Avatar

    Jacob, the workaround I've chosen it simply to map this with hbm for now.

  8. 9 Posted by Jacob Madsen on 23 Jun, 2010 07:14 AM

    Jacob Madsen's Avatar

    Ok, bummer :-)

    Can I see the hbm?

  9. Support Staff 10 Posted by Paul Batum on 27 Jun, 2010 09:22 AM

    Paul Batum's Avatar

    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!

  10. 11 Posted by Peter F. on 28 Jun, 2010 02:20 PM

    Peter F.'s Avatar

    That's awesome, Paul. Is your dev branch relatively stable? Thanks!

  11. Support Staff 12 Posted by Paul Batum on 28 Jun, 2010 11:27 PM

    Paul Batum's Avatar

    Peter, James merged my changes into the official trunk last night so there's
    no need to grab it from my dev branch anymore.

  12. 13 Posted by Peter F. on 29 Jun, 2010 11:35 AM

    Peter F.'s Avatar

    You guys rock. Thanks again!

  13. 14 Posted by cremor on 05 Nov, 2010 10:20 AM

    cremor's Avatar

    Any news on ComponentMaps in collections or as CompositeElement?

  14. Support Staff 15 Posted by James Gregory on 05 Nov, 2010 10:24 AM

    James Gregory's Avatar

    Still not supported, sadly.

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    What day comes after Monday?