-->
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: SELECT not using 'intermediate' data in session
PostPosted: Thu Jun 01, 2006 1:28 pm 
Newbie

Joined: Thu Jun 01, 2006 1:10 pm
Posts: 1
I am running the following code inside a stateful session bean. So I am not using Hibernate transactions. I do an explicit flush() when I want to data to be written to DB.


Code sample1:

Object myObj = ...;
mySession_.save(myObj); //data goes to MY_TABLE
//NOT invoking flush()
String wClause = ....;
List list = mySession_.createQuery("from " + MY_TABLE + " "+ wClause).list();


The list comes out as empty.

But if I insert flush() after save(),

Code sample2:

Object myObj = ...;
mySession_.save(myObj); //data goes to MY_TABLE
mySession_.flush();
String wClause = ....;
List list = mySession_.createQuery("from " + MY_TABLE + " "+ wClause).list();


I get the row back in the list.

When Hibernate transactions are not used, does Hibernate always goes to Database directly for SELECTs and not to transient data in the session (that got inserted by previous saves)? I was hoping to use the session as a cache where I can allow clients of my program to insert, delete and select data at will and finally invoke flush() to persist the session after all the modifications.

Thanks.

Hibernate version: 3.1.3

Name and version of the database you are using: Oracle 10g


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 6:02 pm 
Regular
Regular

Joined: Mon May 22, 2006 2:30 pm
Posts: 74
I think the answer to your question is yes. It's not going to be able to use the session cache when you are using HQL/SQL instead of mapped persistent objects.


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.