aspose file tools*
The moose likes Object Relational Mapping and the fly likes How setCacheable of Query will work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How setCacheable of Query will work " Watch "How setCacheable of Query will work " New topic
Author

How setCacheable of Query will work

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

I have created a query for select Operation in Hibernate using



I think that If i specify setCacheable true of Query then this will not hit the database and return data from Cache ?


Please tell me if my understanding is right or wrong on this ??

Thanks in advance




Save India From Corruption - Anna Hazare.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

The query cache does not cache the entire object, as the first and second level cached do, it caches the query plus the returned identifiers. Remember not all queries willl return whole populated objects after all. Hibernate will uses these identifiers to access data possibly cached in the second level cache. If its not cached there it will hit the database.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you , it was a valuable information .

" Hibernate will sues these identifies to access data possibly cached in the second level cache. "

Can you please tell what the above statement actualy means ?

Thanks in advance.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Sorry, sloppy typing. See above.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234


Thank You very much paul

I have cleared my query with Query Cache .

I have an another query also what if i use cache at Object level . Does this also require second level cache?



 
Consider Paul's rocket mass heater.
 
subject: How setCacheable of Query will work