It means what it says :p You cannot associate an entity with two sessions at the same time. I just took a glance at your code, but if you do need those two sessions, you have to first detach entity from first session if you want to attach it to second one. If you do that, you'll solve your immediate problem, but... I recommend reading about sessions and session management before moving any further.
HTH, peace :) On Mon, Jul 19, 2010 at 10:35 AM, Giulio Petrucci <[email protected] > wrote: > Hi there, > > I've been lurking this mailing list for a while and this is my first post. > :-) > My model is a matrix, like this: > > class Matrix { > IEnumerable <Column> ColumnSet { get; } > IEnumerable <Row> RowSet { get; } > void AddColumn(Column c); > void AddRow(Row r); > } > > class Column > { > Matrix Matrix { ... } > } > > class Row > { > Matrix Matrix { ... } > IEnumerable<Element> ElementSet { get; } > } > > class Element { > Int32 Value { get; } > Row Row { get; } > Column Column { get; } > } > > Every class has an Id property, whici is of Guid type. > When I add a Column (AddColumn() method), automatically a new Element > is added for each Row in the RowSet. > When I add a Row (AddRow() method), automatically an element for each > Column in the ColumnSet si added to the Row I'm adding. > In the mapping files, for Matrix/Column/Row/Element I've set: > cascade="all-delete-orphan". I need to handle one session only to > read data in their actual persistent state (in a sort of db polling): > > Guid id = ...; > ISessionFactory sf = ...; > using (ISession sf.OpenSession()) > { > Element e = s.Get<Element>(id); > //something here; > } > > ..and another session to rea/write data: > > int newValue = ...; > ISession s = ...; > Element r = ...; > > using (ITransaction tx = s.BeginTransaction()) > { > e.Value = newValue; > s.SaveOrUpdate(e); > tx.Commit(); > } > > and here I get an "Illegal attempt to associate a collection with two > open sessions". > As I'm quite a newbie, my my questions are: > 1. What does it mean? ;-) > 2. How can I fix it? > > Thanks in advance. Have a nice day/week, > Giulio > > -- > > -- > 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]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- 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.
