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?
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.
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.
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?
Post by:autobot
Eat that pie! EAT IT! Now read this tiny ad. READ IT!
a bit of art, as a gift, the permaculture playing cards