Good timing, someone posted a similar issue with collection type just recently: http://support.fluentnhibernate.org/discussions/help/20-preventing-mapping-output-for-custom-collection-type
The change won't be available in the trunk until James pulls my changes through but hopefully that'll happen in the next day or two. On Fri, Mar 5, 2010 at 9:38 PM, Gabriel Schenker <gnschen...@gmail.com>wrote: > we are currently converting our hbm files to fluent mappings to be > more flexible and leverage the power of conventions as an example. > During this exercise I encountered some "exotic" <bag> mappings. They > look similar to this: > > <class name="...Field, AssemblyName> > ... > <bag name="Options" access="SomeNamespace.GenericAccessor > +CamelCase, AssemblyName" > generic="true" inverse="true" cascade="all-delete-orphan" > lazy="true"> > <key column="PARENT_FIELD_ID" /> > <one-to-many class="SomeOtherNamespace.Option, AssemblyName"/> > </bag> > ... > </class> > > and the entity: > > public class Field : ... > { > ... > private VersionList<Option> options; > .... > } > > Here the VersionList<T> is kind of a wrapper around an inner list of > type IList<T>. > The GenericAccessor is responsible to map to this 'innerList'. The > mapping when using the hbm file works like a charm. > > I tried to translate this to > > HasMany(x => x.Options) > .Access.Using("SomeNamespace.GenericAccessor > +CamelCase, AssemblyName") > .KeyColumn("PARENT_FIELD_ID") > .Generic() > .Inverse() > .Cascade.AllDeleteOrphan() > .LazyLoad(); > > the problem is now that the above fluent mapping translates into a bag > that contains a 'collection-type' attribute which then causes > problems. A mapping exception is thrown. To work correctly this > attribute must NOT be present. > > To solve this I did the following HACK(!, but it works): I modified > the Fluent NHibernate source such as that the HasManyPart contains a > member NoCollectionType() which removes any entry from the attributes > store; thus when creating the xml mapping the attribute is not > written. I know this is a terrible hack but I did not find any other > solution. > > what would be a better solution? (maybe I should implement an > IUserCollectionType but there is very little info around about how to > correctly do this and it is even outdated or contradicting info...) > > -- > You received this message because you are subscribed to the Google Groups > "Fluent NHibernate" group. > To post to this group, send email to fluent-nhibern...@googlegroups.com. > To unsubscribe from this group, send email to > fluent-nhibernate+unsubscr...@googlegroups.com<fluent-nhibernate%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/fluent-nhibernate?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to fluent-nhibern...@googlegroups.com. To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.