Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Re: Caching read-all queries

I've already tried the following:

       Session session =

        ReadAllQuery q = new ReadAllQuery(Person.class);
        q.setJPQLString("SELECT OBJECT(p) FROM Person p");
        List args = new ArrayList();
        q.setQueryResultsCachePolicy(new QueryResultsCachePolicy(new
        List list = session.executeQuery(q, args);

Despite this, it still prints the SQL twice in the logs on successive
calls.  This is based on the example shown here:

On Wed, May 19, 2010 at 6:05 PM, Zarar Siddiqi <zarars@xxxxxxxxx> wrote:
> I'm using 1.2 and have a couple cache related questions.
> Do read-all queries (ones using getResultList()) always hit the database?
> As I understand the docs, the "CheckCacheThenDatabase" hit only
> applies to read-object queries (ones using getSingleResult()).  In my
> app, I have a ton of queries that are candidates for caching, but they
> all use getResultList(). I've set an @Cache(expiry=60000) annotation
> on those entities and when I execute them, I keep seeing the queries
> printed in the logs.
> To me, this isn't the greatest behaviour since I'm executing the exact
> same query with the exact same parameters.  Shouldn't EclipseLink have
> a way of optimizing this?
> Thanks,
> Zarar

Zarar Siddiqi

Back to the top