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: CreateSQLQuery locking up app
PostPosted: Tue Aug 25, 2009 4:47 pm 
Newbie

Joined: Tue Aug 25, 2009 4:39 pm
Posts: 1
Hey, someone else on our dev team did most of the low level nHibernate work, so I am not exactly sure how it's all supposed to work, any tips would be appreciated. We have had issues with data sessions and multiple threads in the past, so I know he did a lot of tweaking.

anyway, when I use CreateSQLQuery to do direct SQL query, it locks up the app - not immediately, but eventually - I think next time a query is made. Here is my code:

// Note, the sql query can be a long query with multiple joins...

var query = _dataContext.Session.CreateSQLQuery(sql);
query.AddEntity("Studies", typeof (Study));
query.SetCacheMode(CacheMode.Refresh);
var results = query.List<TEntity>();
return results.Cast<TEntity>().ToList();

If I close the session immediately, it seems to work ok, but then in other areas in our app I get a Session Closed exception.... ?

Any ideas? I know it's kind of hard withuot knowing our full architecture, but if any one has anything to look out for, that would be great.

thanks,

dan


Top
 Profile  
 
 Post subject: Re: CreateSQLQuery locking up app
PostPosted: Wed Aug 26, 2009 11:30 am 
Regular
Regular

Joined: Wed Feb 11, 2009 10:58 am
Posts: 55
I can't say anything on the SQL Query itself. But the session closed exception could be caused by lazy loading.
If you close a session an object becomes detached. If you try to access a lazy loaded property (which is not already in memory) on a detached object you get a session closed exception.


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.