hibernate query cache
http://tech.puredanger.com/2009/07/10/hibernate-query-cache/
hibernate 2nd level cache and query cache
query cache with key on "query + parameters [could be ptr to object]", values is the "id" of the returned entities (may consider value object !!!)
native sql (not using criteria) will cause invalidation of all the cached entries (invalidate all tables) because hibernate does not parse the query. There exist API in hibernate (some addSync.... function calls) to declare which region space, what table (for native sql, empty region space => no invalidation), which classes.
Second level cache is associated with the connection factory.
An API exist to invalidate the cache (use evict(...)).
Any Out-of-band changes on DB, the second level or query cache won't know about it. It is the responsibility of the user.
2nd level cache and query cache can work together.
The identity got from the query cache (or from database) can be used to look up entity (pseudo) from 2nd level cache.
2nd level cache does not store the entity object, its association as object .
In stead, it flatten the object (dehydrate) and store its properties as name/value pair, any association will be replaced by id, association (cached) will be stored as array of ids.
hibernate 2nd level cache and query cache
query cache with key on "query + parameters [could be ptr to object]", values is the "id" of the returned entities (may consider value object !!!)
native sql (not using criteria) will cause invalidation of all the cached entries (invalidate all tables) because hibernate does not parse the query. There exist API in hibernate (some addSync.... function calls) to declare which region space, what table (for native sql, empty region space => no invalidation), which classes.
Second level cache is associated with the connection factory.
An API exist to invalidate the cache (use evict(...)).
Any Out-of-band changes on DB, the second level or query cache won't know about it. It is the responsibility of the user.
2nd level cache and query cache can work together.
The identity got from the query cache (or from database) can be used to look up entity (pseudo) from 2nd level cache.
2nd level cache does not store the entity object, its association as object .
In stead, it flatten the object (dehydrate) and store its properties as name/value pair, any association will be replaced by id, association (cached) will be stored as array of ids.
0 Comments:
Post a Comment
<< Home