Forums Register Login

regarding QueryCache

+Pie Number of slices to send: Send
Hi....Friends,

I'm new to hibernate,could Anybody explain to me what is org.hibernate.cache.QueryCache.?Is this query cache is second cache or Is this relate to session-factory?
+Pie Number of slices to send: Send
The query cache is not the second level cache, it is a distinct cache to store the reqults of queries. Hibernate includes three caches:
  • The first level cache (i.e. the Session)
  • The second level cache
  • The query cache


  • You use the first level cache all the time, the other two are optional. You use the second level cache to store data retrieved from the database as it is loaded in to the session if you configure your mapped classes to do this. The query cache doesn't store data in the same way, it maintains a cache of identifiers that represent result sets from queries and these identifiers are used to access the underlying entitites. Because of this it makes no sense to use the query cache without the second level cache.

    Something worth noting: using the second level cache is relatively unusual. Most database backed applications can't tolerate data being held in a cache for a long time. The query cache is therefore even less frequently used. If you have performance problems with querying in Hibernate the query cache is probably the last thing you would look to implement to try to improve things.
    +Pie Number of slices to send: Send
    Hi Paul,
    Thanks for your reply.

    one more doubt, Is second-level-cache is associates with session-Factory object[/i]?
    +Pie Number of slices to send: Send
    I'm not strictly sure I understand your question. The SessionCaftory is a factory that provides Sessions. Sessions are used to access data. This data may come from the database or may be read out of the second level cache if you are using one.
    +Pie Number of slices to send: Send
    Hi....
    My Question is First-level-cache(i.e session) is associates session object,Right?same like that Is second-level-cache is associates with session-Factory object?
    Eat that pie! EAT IT! Now read this tiny ad. READ IT!
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 1133 times.
    Similar Threads
    Regarding clustering
    Second level cache does not work
    struts, hibernate 2.1 and jboss 4.0.0
    Hibernate Caching
    java.lang.UnsupportedOperationException: The user must supply a JDBC connection
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 29, 2024 06:47:50.