Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Difference between cache-usage and maintain-cache query hints?

Comments inline:

Laird Nelson wrote:
On Thu, Mar 17, 2011 at 9:23 AM, Tom Ware <tom.ware@xxxxxxxxxx <mailto:tom.ware@xxxxxxxxxx>> wrote:

     Cache_Usage controls whether the cache is used to get results in a
    read. e.g. if you set the cache usage to CheckCacheThenDatabase when
    this query is executed, results in the cache will be prioritized
    over results in the DB.


OK; my understanding was this only applied to individual objects. So if I had a query like

  SELECT o FROM SomeEntity o WHERE o.id <http://o.id> = :pk

...then o would be retrieved from the cache. The documentation begins talking about ReadObject queries vs. ReadAll queries, which of course mean nothing to me as I'm coding to the JPA API.

Any query that retrieves multiple results will go to the database unless explicitly told not to go to the database at all. We have to do this to ensure we get any results that are in the DB, but not our cache. When the cache is used, our initial DB retrieval looks at the primary keys returned from the database and uses those to retrieve any objects we already have in the cache. EclipseLink then builds any objects not available from the cache.

For queries returning single results it is possible to configure them so they use what is called a ReadObjectQuery, which is designed to return a single result. ReadObjectQuerys can run without going to the DB at all when the result is available in the cache.



Then I also found (somewhere else) the eclipselink.query-results-cache query hint, which would seem to be the same thing. Should I use one of these hints? Both of them?

The query results cache query hint is not quite the same. You should only use this query hint for absolutely static data. When you use a query-results-cache, the database will only be hit once. Every time you use the query it will return the same results as the first usage.

-Tom


Thanks very much for your help.

Best,
Laird


------------------------------------------------------------------------

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top