OK, then I did replace all ISet<> with HashSet<>. Also, commented the
collection factory line.

The configuration passes, on save, I get the following error:

{"Unable to cast object of type
'NHibernate.Collection.Generic.PersistentGenericSet`1[FluentNHSampleApp.Domain.Customization]'
to type
'System.Collections.Generic.HashSet`1[FluentNHSampleApp.Domain.Customization]'."}

Relevant classes (skipping EntityBase that keeps the Id):


    public class Product : EntityBase
    {
        private readonly HashSet<Customization> customizations;

        public Product()
        {
            customizations = new HashSet<Customization>();
        }

        public virtual string Name { get; set; }
        public virtual decimal Price { get; set; }

        public virtual HashSet<Customization> Customizations
        {
            get { return customizations; }
        }
    }

    public class Customization : EntityBase
    {
        private readonly HashSet<string> possibleValues;

        public Customization()
        {
            possibleValues = new HashSet<string>();
        }

        public virtual string Name { get; set; }

        public virtual HashSet<string> PossibleValues
        {
            get { return possibleValues; }
        }
    }

Supposedly relevant generated XML mapping:

    <set access="nosetter.lowercase" cascade="all"
name="Customizations">      <key>        <column name="Product_id" />
    </key>      <one-to-many
class="FluentNHSampleApp.Domain.Customization, FluentNHSampleApp,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />    </set>


Here is what the Save code looks like (copy paste from Jose's orking confORM
example):

            using (ITransaction tx = s.BeginTransaction())
            {
                var product = new Product
                                  {
                                      Name = "Fideos",
                                      Customizations =
                                          {
                                              new Customization
                                                  {
                                                      Name = "Tuco",
                                                      PossibleValues =
{"Pocon", "Medio", "Sopa"}
                                                  }
                                          }
                                  };

                s.Save(product);

                tx.Commit();
            }

 Any ideas? Thanks again.

*Mohamed Meligy
*Readify | Senior Developer

M:+61 451 835006 | W: readify.net
[image: Description: Description: Description: Description:
rss_16]<http://gurustop.net>
[image: Description: Description: Description: Description:
cid:image003.png@01CAF81D.6A076510]
<http://www.linkedin.com/in/meligy>  [image:
Description: Description: Description: Description:
cid:image005.png@01CAF81D.6A076510] <http://twitter.com/meligy>
 
<http://www.greatplacetowork.com.au/best/best-companies-australia.php><http://www.readify.net/AboutUs/NewsItem.aspx?id=10>



On Sun, May 1, 2011 at 8:55 PM, James Gregory <jagregory....@gmail.com>wrote:

> CollectionTypeResolver definitely looks like the place we should be
> changing, and ideally adding a callout to something configurable.
>
> Your second example isn't anything to worry about, that's a part of the
> PersistenceSpecification stuff (a testing tool for mappings). It's not
> actually used to generate mappings. You're correct in that it wouldn't work,
> but it won't affect your mappings in any way.
>
> HashSet is a .Net 3.5 collection, so the collection factory stuff isn't
> necessary. It should just work straight out of the box.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Fluent NHibernate" group.
> To post to this group, send email to fluent-nhibernate@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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@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.

Reply via email to