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.  [ 1 post ] 
Author Message
 Post subject: Error: "owning Session was closed"
PostPosted: Thu Jun 22, 2006 4:48 pm 
Regular
Regular

Joined: Sun Feb 12, 2006 10:18 pm
Posts: 60
Location: Rosario, Argentina
I have the logged user (Class: User) inside a Session variable.
The User has a collection of items of class Log (User.Logs) which is lazyly initialized.
I'm also using the Open-Session-In-View Pattern.

At some point, I use this code:


Code:
protected void ddlLogHistoryFilter_SelectedIndexChanged(object sender, EventArgs e)
{
    User rUser = ((User)Session["LoggedUser"]);
    theSession.Lock(rUser, None);
    System.Collections.Generic.List<Log> logHistory = new System.Collections.Generic.List<Log>();

    //some logic to filter and add the Logs from User.Logs to logHistory

    gridViewLogHistory.DataSource = logHistory;
    gridViewLogHistory.DataBind();
}


When I run this the first time, it works perfectly. But when I change the dropDownList selected item (thus firing the above procedure, it has AutoPostBack = true), when the debug gets to

gridViewLogHistory.DataBind();

NHibernate throws this error:

Could not initialize proxy - the owning Session was closed

I don't know why this is happening, my guess is User.Logs is cached somewhere thus the original session is closed, though I reattach User to the new session (with theSession.Lock) so if this is the case, I don't know why would this happen...

Can anyone help me?

Alejandro.


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

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.