I read the article in http://www.javalobby.org/java/forums/t48846.html which explain Hibernate Query Cache but I couldn't completely understand how it works.
As the article explain:
Query query = session.createQuery("from Person as p where p.parent.id=? and p.firstName=?");
query.setInt(0, Integer.valueOf(1));
query.setString(1, "Joey");
query.setCacheable(true);
List l = query.list();
The query cache works something like this:
*----------------------------------------------------------------------------------------*
| Query Cache |
|----------------------------------------------------------------------------------------|
| ["from Person as p where p.parent.id=? and p.firstName=?", [ 1 , "Joey"] ] -> [ 2 ] ] |
*----------------------------------------------------------------------------------------*
The combination of the query and the values provided as parameters to that query is used as a key, and the value is the list of identifiers for that query.
Question 1: What are identifiers in this? Are they the entities' ID in query result?
Question 2: Hibernate's documents say
For example, if you cache results of a query against an object, Hibernate needs to keep track of whether any changes have been committed against the object, and invalidate the cache accordingly
If the answer for question 1 is YES(they are the entities' ID in query result), Does this mean the cached keep timestamps when a table was last updated and decide to refresh cache if needed?
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments