-->
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.  [ 3 posts ] 
Author Message
 Post subject: bad stale delete in session.
PostPosted: Fri Oct 20, 2006 5:05 pm 
Newbie

Joined: Fri Apr 01, 2005 5:20 pm
Posts: 14
Hibernate version: latest

Code between sessionFactory.openSession() and session.close():
Not closing my session really. This is a winform app and I just leave it open. This might be part of my problem.

Full stack trace of any exception that occurs:
://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>ProTrac.vshost.exe</AppDomain><Exception><ExceptionType>NHibernate.ADOException, NHibernate, Version=1.0.2.0, Culture=neutral, PublicKeyToken=154fdcb44c4484fc</ExceptionType><Message>could not delete: [DTP.Data.ProjectType#21]</Message><StackTrace> at Lucas.ObjectAccess.HibernateObjectAccessComponent.GetList(Type type) in C:\projects\Lucas\Lucas\ObjectAccess\HibernateObjectAccessComponent.cs:line 226
Name and version of the database you are using:
MsSQL 2000

Hi,

I am having a problem with a failure to delete an object due to a FK constraint. I get an exception back, but I am not sure how to handle the session afterwards. The app appears to handle the exception fine. The user gets a dialog box and hit ok and trys to move on. The problem is when I try to get a list of object next, it still tries to delete the object from before.

So my question is how do I get rid of the previous delete/object when I catch my exception? I have tried to flush, refresh and evict, but I am missing something.

_________________
Thanks,

John


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 8:07 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
You need to open a new session.
A session is not exception safe.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 21, 2006 3:22 pm 
Newbie

Joined: Fri Apr 01, 2005 5:20 pm
Posts: 14
Hmmm Thanks for that. I have tried a few version of the following, but still missing something.


catch (Exception ex)
{
Console.WriteLine("Exception in HOAC " + ex.Message);
if (tx != null)
{
tx.Rollback();
}
Console.WriteLine("Exception in HOAC " + ex.Message);
m_session.Close();
m_session = null;
if ((m_session == null) || (!m_session.IsOpen))
{
Console.WriteLine("Opening a new Session.");
m_session = GetSessionFactory().OpenSession();
}


throw ex;
}

When I go to get another list I get this execption:
System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>ProTrac.vshost.exe</AppDomain><Exception><ExceptionType>System.ObjectDisposedException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Session was disposed of or closed
Object name: 'ISession'.</Message><StackTrace>

Thanks for the help.

_________________
Thanks,

John


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.