All, I've come across an odd situation with NH and the Version settings. My App uses generic ICollections and map these to sets. It works fine without any problems.
However, if i add the Version setting to the mapping file I get intermittent problems such as: Unable to cast object of type 'System.Collections.ObjectModel.Collection`1[Entities.Allocation.OrderItem]' to type 'Iesi.Collections.ISet'. This occurs when I perform a save of the root object (the order) then flush. The Order has the version setting, not the Order Item. Our C# is (e.g.) private ICollection<OrderItem> _orderItems; initialised via: _orderItems = new Collection<OrderItem>(); in the constructor of the class. I'm going off the post from Ayende where he states you don't need to use IESI.Collections any more (I used to have " _orderItems = new HashSet<OrderItem>(); " as suggested, but that fell over too with something similar to "cannot cast HashSet to type 'Iesi.Collections.ISet'. " http://ayende.com/Blog/archive/2009/04/23/nhibernate-tidbit-ndash-using-ltsetgt-without-referencing-iesi.collections.aspx The code works fine if I don't use Version, but then I'll have to roll my own, which sort of defeats the point. Snipped mapping file: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Entities.Allocation" assembly="Domain" default-access="field.camelcase-underscore" default-lazy="true"> <class name="Order" table="Allocation.[Order]"> <id name="Id" column="Id" type="int" unsaved-value="0"> <generator class="hilo"> <param name="max_lo">2</param> <param name="where">Entity='Order'</param> </generator> </id> <version name="Version" column="Version" type="int" /> ..... <set name="OrderAllocations" table="Allocation.OrderAllocation" inverse="true" cascade="all-delete-orphan" > <key column="OrderId" /> <one-to-many class="OrderAllocation" /> </set> </class> </hibernate-mapping> -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
