Exception "Illegal attempt to associate a collection with two open sessions" when saving object

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-03-19T14:59:57Z Indexed on 2010/03/19 15:01 UTC
Read the original article Hit count: 270

Filed under:

I am using CastleProject ActiveRecord and I use lazy load feature of this ORM. In order to make lazy load work, it is required to create SessionScope. I do this in Program.cs:

public static SessionScope sessionScope;

private static void InitializeActiveRecord()
{
  ActiveRecordStarter.Initialize();
  sessionScope = new SessionScope();
}

This works fine for loading, however, when I try to save my objects, I get an exception saying "Illegal attempt to associate a collection with two open sessions". I guess this is due to the fact that I created one session myself.

How to avoid this exception?

© Stack Overflow or respective owner

Related posts about castle-activerecord