Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How setCacheable of Query will work

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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



 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, sloppy typing. See above.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic