-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: collection with two open sessions
PostPosted: Wed Jun 22, 2005 12:12 pm 
I am looking for the proper way to implent the following situation (using asp.net 2.0 and NHibernate 0.8.4.0):

Code:
class Foo
{ //some fields and properties
  prviate IList myManyToManyCollection;
  public IList MyManyToManyCollection
  {
     get{return myManyToManyCollection;}
  }
...
}


I have no issues populating the collection via Nhibernate and everything seems to save and update properly.

My page maintains an IList that represents this many-to-many collection in Session[] from which the user can add or delete members from this IList using a web interface.

My desire is to replace the IList in my class with the IList maintained in session imediatly prior to the class being saved into the data base.

My current approach is the following:
Code:
protected void odsFoo_Updating(object sender, ObjectDataSourceMethodEventArgs e)
{
        Foo f = e.InputParameters[0] as Foo;

       //grab my updated list out of session
       _myLocalIList = Session["myLocalList"] as IList;

       //stick it into my class so it will get saved
        f.MyManyToManyCollection = _myLocalIList;
}


(odsFoo is my object data source)

This causes the following error when Nhibernate calls

Code:
       
       ISession session = orm.GetSession();

   try
   {
     session.BeginTransaction();
---->   session.SaveOrUpdate(obj);
     session.Transaction.Commit();
   }
      


"Illegal attempt to associate a collection with two open sessions "

As far as I can tell my sessions are closed, but I am realativly new to hibernate so I may have a gross misunderstanding of the process.

Any help or advice on tackling this issue would be appreciated.

[/code]


Top
  
 
 Post subject:
PostPosted: Wed Jun 22, 2005 3:39 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Probably the session that you used to load the many-to-many collection originally wasn't closed.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.