| Author |
Query Level Cache
|
lavnish lalchandani
Ranch Hand
Joined: Feb 28, 2007
Posts: 78
|
|
Hi
I understand difference between 1st level and 2nd level cache.
Wanted to understand How is query level cache different from 1st and 2nd Level Cache
as per my understanding if i run a query with ? ie
from employee emp where emp.id=?
then only it can be cached in a 2nd Level cache … so query like
from employee emp where emp.id=123
will not be cached .. to cache these a query cache is used , right ?
BUT in my code if i have queries as below ... do we see one DB hit or Two DB hit
from employee emp where emp.id=123
from employee e where e.id=123
// extra spaces in query string + e used instead of emp
|
lavnish.blogspot.com
|
 |
Gopakumar Naryanan
Ranch Hand
Joined: Jan 15, 2011
Posts: 72
|
|
The following Link may guide you precisely
Hibernate Cache Strategies
All The Best
|
Thanks & Regards
Gopakumar
|
 |
Salil Vverma
Ranch Hand
Joined: Sep 06, 2009
Posts: 219
|
|
Hi lavnish,
Second level cache stores the object in a map, having primary key as Map's key and Object as map value. Second level cache is used only while accessing the object by primary key ie by using session.get(), session.load().
Query cache store the query result in map, having query and its parameters as Map's key and result as map value. Query cache can be used to cache & reuse the result of any query irrespective of primary key usage in it.
|
Regards
Salil Verma
|
 |
 |
|
|
subject: Query Level Cache
|
|
|