-->
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.  [ 4 posts ] 
Author Message
 Post subject: Querying the session for (as yet) uncommitted changes
PostPosted: Mon Jul 21, 2008 4:05 am 
Beginner
Beginner

Joined: Fri Oct 27, 2006 3:35 pm
Posts: 21
Hi Folks,

I'm developing a web application using Hibernate. During the scope of a single Hibernate Session & Transaction, objects may be created, persisted and subsequently queried for (using hql). This last bit presents a problem, since at the point these objects are queried for the session has not yet been flushed thus the hql query returns nothing.

Is there some way in which I can include these un-flushed objects, sitting in the Hibernate Session, in my hql queries?

Cheers,
Richard.

Hibernate version:

3.2.6

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 21, 2008 4:35 am 
Beginner
Beginner

Joined: Fri Oct 27, 2006 3:35 pm
Posts: 21
After having a read through some of the previous posts on this forum, it looks like it's expected functionality for Hibernate NOT to search it's cache for unflushed objects. This is something that we most certainly need to do, so does anyone have any recommendations for how this should be done?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 21, 2008 5:33 am 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
The standard aproach would be to configure Hibernate to flush before query. (search the docs for FlushMode). If this doesn't work for you you are pretty much on your own.

_________________
Please rate useful posts.


Schauderhaft: Softwaredevelopment, Projectmanagement, Qualitymanagement and all things "schauderhaft"


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 21, 2008 5:47 am 
Beginner
Beginner

Joined: Fri Oct 27, 2006 3:35 pm
Posts: 21
Thanks for your reply. I'd kind of figured we were probably going to be on our own!

I think we're going to have to implement our own Session, which looks at the cache before performing a query against the db.

Cheers.


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