-->
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.  [ 9 posts ] 
Author Message
 Post subject: inserting data manually and 2nd level cache
PostPosted: Thu Mar 27, 2008 3:08 pm 
Beginner
Beginner

Joined: Wed Mar 19, 2008 12:10 am
Posts: 36
if i'm using 2nd level cache... and i manually insert some data into the db via command line (not using a hibernate session)... will the cache return old data to users?


Top
 Profile  
 
 Post subject: Re: inserting data manually and 2nd level cache
PostPosted: Thu Mar 27, 2008 3:15 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
ew0kian wrote:
if i'm using 2nd level cache... and i manually insert some data into the db via command line (not using a hibernate session)... will the cache return old data to users?


If you are inserting then no because the data didn't exist before but I assume you are talking about updating data that is cached in a L2 Cache. In that case it depends. Entities are fetched off a L2 Cache only when they are selected with a key. This include all find by primary key methods and/or relations that are fetched with a select. HQL queries or SQL queries do not use a L2 Cache. At the same time, you can set a limit for the amount of time an entity stays in a L2 Cache so that you make sure at least every xx seconds you get fresh data.



Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 27, 2008 3:51 pm 
Beginner
Beginner

Joined: Wed Mar 19, 2008 12:10 am
Posts: 36
okay thanks for the explanation on how the 2nd level cache works!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 27, 2008 3:52 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
ew0kian wrote:
okay thanks for the explanation on how the 2nd level cache works!


I have to correct myself when I said HQL queries do not use a L2 Cache. This is true if query caching is disabled.



Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 27, 2008 5:16 pm 
Beginner
Beginner

Joined: Wed Mar 19, 2008 12:10 am
Posts: 36
so if there's a table that is quite large and will be read only, it would make sense for the queries to that table to be cached by doing Query.setCachable(true) before the actual execution of query.iterate()? this will cause it to save the results in memory?

this would be able to speed up performance if users where using the same search string more than once correct?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 27, 2008 8:44 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
ew0kian wrote:
this would be able to speed up performance if users where using the same search string more than once correct?



True. Query results are saved by query parameter's values so there will 1 database hit if the same query is fired multiple times. A query's cache is throw away if one of the participating entities is updated with a hibernate session.




Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 5:33 am 
Newbie

Joined: Sat Oct 20, 2007 2:43 am
Posts: 11
Hi All,

if we are updating some data into a collection, will hibernate reloads the whole collection from the database into the cache?


Thanks
Pawan Chopra.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 5:33 am 
Newbie

Joined: Sat Oct 20, 2007 2:43 am
Posts: 11
Hi All,

if we are updating some data into a collection, will hibernate reloads the whole collection from the database into the cache?


Thanks
Pawan Chopra.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 2:24 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
pawanspace wrote:
if we are updating some data into a collection, will hibernate reloads the whole collection from the database into the cache?


I'd say no but be more specific so that I can tell you what happens.


Farzad-


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