-->
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.  [ 8 posts ] 
Author Message
 Post subject: Some sort of caching problem... I think.
PostPosted: Wed May 31, 2006 11:49 am 
Newbie

Joined: Tue Apr 25, 2006 4:34 am
Posts: 11
Hibernate version:
3

Query.list() returns a List containing three objects. After that I add a row to the database (not using Hibernate), and then run the query again, and it still only returns three obejcts, though it should be four.
Is this because of some kind of caching? I read something in the docs about query caching, but that thing was supposed to be turned off by default...


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 1:19 pm 
Beginner
Beginner

Joined: Fri May 26, 2006 7:15 am
Posts: 20
Location: Vandavasi, TamilNadu
commit after inserting -- ?

_________________
gajini
------------------


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 3:35 am 
Newbie

Joined: Tue Apr 25, 2006 4:34 am
Posts: 11
gajini wrote:
commit after inserting -- ?

I'm not using hibernate to do the insert.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 4:10 am 
Beginner
Beginner

Joined: Tue Nov 22, 2005 5:33 am
Posts: 31
Check if you have set the property
<property name="hibernate.cache.use_query_cache">true</property>

In that case the result of the query will be cached and you will not see the post inserted.

If you don't have that property, or it is set to false, your resultset will not be cached and your problem is somewhere else.

_________________
Emil
Don't forget to rate, I'm desperate!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 4:15 am 
Beginner
Beginner

Joined: Tue Nov 22, 2005 5:33 am
Posts: 31
On second thought, for Hibernate, you need to set cacheable to true for each query, otherwise it won't be cached:
session.createQuery("from Object o").setCacheable(true).list();

If you haven't done this I would agree with the previous poster, you probably haven't commited the insert.

_________________
Emil
Don't forget to rate, I'm desperate!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 4:38 am 
Newbie

Joined: Tue Apr 25, 2006 4:34 am
Posts: 11
I'm 100% sure the rows are inserted correctly. I insert them manually using Navicat (MySql gui).

And if I restart Tomcat hibernate finds the new rows correctly.

I have nothing about query caching in my code or property file.

I'm working om a web application and all hibernate stuff lies in a separate jar file, datalayer.jar.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 4:59 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi,

If you are using session do flush the session.
i.e) session.flush()

If you have already flushed the session, refresh the session.
i.e) session.refresh()

Ideally when you flush the session the inserted record showed be in the List.

If this doesn't solve the problem do post the code segment!!!!!!!!!

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 6:43 am 
Newbie

Joined: Tue Apr 25, 2006 4:34 am
Posts: 11
The problem was not in Hibernate but in MySql. Solved it by putting
"transaction-isolation = READ-COMMITED"
in the config file.

Thanks anyway for your answers, I think they helped me tracking down the problem so I'll give you some credits. =)


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