-->
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: Caching objects when inserted
PostPosted: Thu Jun 16, 2005 3:03 am 
Newbie

Joined: Thu Jun 16, 2005 12:43 am
Posts: 4
hello

I'm using the latest Hibernate release with EHCache as a second-level cache. All settings are pretty much default. The app uses very simple bean-like objects with no association, but the rate of writes and reads is very high.

I turned statistics on and noticed that I have 0 second-level cache hits for selects, so apparently all objects are fetched from database.

I wonder if there's a way to make this setup store objects in the second-level cache and fetch then from there instead of selecting from database. Even if there's only one select for each object. Basically using Hibernate + cache as an in-memory object smart cache. Or is it only possible for session first-level cache?
I thought second-level cache did that too but apparently not...

all comments will be greatly appreciated

thanks

Denis.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 3:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if you execute queries then we have to go to the database to resolve it - neither first or second level cache is a full fledged SQL database ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2005 10:50 pm 
Newbie

Joined: Thu Jun 16, 2005 12:43 am
Posts: 4
Oh... I thought if the identity is set up properly, then, under certain scope settings, Hibernate will first look up the cache for the object...
What is the second-level cache for then?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 18, 2005 1:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
its all in the doc - caches are for looking up entities by *id* to improve performance.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 18, 2005 9:35 am 
Regular
Regular

Joined: Thu Apr 21, 2005 9:05 am
Posts: 50
Location: Boston, U.S
Hi Max,

I have a similar question for Query Caching.
If i execute select queries multiple times the data is read from the cache

but if i make any insert to the table and query mulitple time using
query cache it is not read from cache but an sql is triggered.

It would be greatful if you could give some pointers regarding
this issue.

Regards


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 18, 2005 12:22 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
sorry - but all this is explained in great detail in ref. doc, Hibernate in Action and our training........sorry - but to hot weather here now for me to reexplain stuff :)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 19, 2005 8:25 pm 
Newbie

Joined: Thu Jun 16, 2005 12:43 am
Posts: 4
max wrote:
its all in the doc - caches are for looking up entities by *id* to improve performance.


Yeah that's what I thought - I look up entities by *id*. Insert and then look up by *id*. And still get 0 cache hit, but I also 0 cache miss.... Hibernate in Action does say that caches help when lookup by *id* is conducted, but I'm still having a problem.... :)
thanks though.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 20, 2005 1:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
and looking up by id (that will look in the cache) is *not* done via a query/criteria, but via .get()/.load() or object navigation.

_________________
Max
Don't forget to rate


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.