[
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?
|
On Wed, Mar 16, 2011 at 4:10 PM, Laird Nelson
<ljnelson@xxxxxxxxx> wrote:
My use case is the exceptionally brain-dead common example of caching a list of drop-down options. The JPQL query in question is basically like one you'd write for U. S. states:
SELECT s FROM State s ORDER BY s.code;
If I wanted this query to return results from the cache whenever possible, which of these two query hints should I use? Or is there (preferably) a JPA-sanctioned query hint that would do the same thing?
Wow, it's even more complicated:
http://www.eclipse.org/eclipselink/api/2.2/org/eclipse/persistence/config/QueryHints.html#QUERY_RESULTS_CACHE says, bafflingly:
Configures the query to use a results cache.
By default the query will cache 100 query results, such that the same named query with the same arguments
is re-executed it will skip the database and just return the cached results.
That part isn't baffling--that sounds like exactly what I want! But then it goes on to say:
Valid values are: HintValues.PERSISTENCE_UNIT_DEFAULT, HintValues.TRUE, HintValues.FALSE,
"" could be used instead of default value HintValues.PERSISTENCE_UNIT_DEFAULT.
By default query results are not cached.
This is not, and is independent from the object cache.
(This is not...what?) What
is the default? Is it FALSE, or PERSISTENCE_UNIT_DEFAULT? If this is the way to handle this use case, why is it not mentioned here:
http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#How_to_Use_EclipseLink_JPA_Query_Hints? Does this mean that I cannot use eclipselink.query-results-cache as a JPA query hint? If I can, then why isn't it in the list of valid JPA query hints?
Benevolently confused,
Laird