Ian, what you are seeing mean that the problem is your session management strategy.
2009/6/26 ian <[email protected]> > > Any tips on how do I solve it? I tried to close the session after > feeding it to an IList and on populating it to a listview, it says > "Could not initialize proxy - the owning Session was closed. > > On Jun 26, 9:52 pm, Fabio Maulo <[email protected]> wrote: > > Illegal attempt to associate a collection with two open sessions. > > 2009/6/26 ian <[email protected]> > > > > > > > > > > > > > I'm getting an illegal attempt error when updating. I have a TruckLoad > > > class that has TruckLoadItem class. This is my mapping > > > > > <?xml version="1.0" encoding="utf-8" ?> > > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > > > namespace="Bogetz.Elephant.Model" assembly="elephant"> > > > > > <class name="TruckLoad" table="truck_loads"> > > > <id name="Id"> > > > <generator class="native"/> > > > </id> > > > <property name="Date"/> > > > <many-to-one name="Route" class="Route" > column="RouteId"/> > > > <many-to-one name="Salesman" class="Salesman" > > > column="SalesmanId"/> > > > <property name="TruckNo"/> > > > <property name="PreparedBy"/> > > > <property name="ApprovedBy"/> > > > <property name="ReleasedBy"/> > > > <property name="RecordedBy"/> > > > <bag name="Items" cascade="all"> > > > <key column="TLId"/> > > > <one-to-many class="TruckLoadItem"/> > > > </bag> > > > </class> > > > > > <class name="TruckLoadItem" table="truck_load_items"> > > > <id name="Id"> > > > <generator class="native"/> > > > </id> > > > <many-to-one name="Load" class="TruckLoad" column="TLId"/> > > > <many-to-one name="Item" class="Item" column="ItemId"/> > > > <property name="Quantity"/> > > > <property name="UnitPrice"/> > > > <property name="Amount"/> > > > </class> > > > > > </hibernate-mapping> > > > > > This happens when I call return NHibernateHelper.OpenSession > > > ().CreateCriteria(typeof(TruckLoad)).List<TruckLoad>(); and populate > > > the list into a listview. When double clicked, I get the > > > > > TruckLoad t = (Model as List<TruckLoad>)[listView1.SelectedItems > > > [0].Index]; > > > > > and feed it to TruckLoadForm, when I do SaveOrUpdate(TruckLoad), I get > > > the error. I'm kinda lost to where I can find the solution. Please > > > help, thanks a lot. > > > > -- > > Fabio Maulo > > > -- Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
