Skip to main content

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

I believe even if EL is hitting the cache you'll still see the SQL in the logs. 

./tch


On Wed, May 19, 2010 at 8:53 PM, Zarar Siddiqi <zarars@xxxxxxxxx> wrote:
I've already tried the following:

      Session session =
JpaHelper.getServerSession(em.getEntityManagerFactory());

       ReadAllQuery q = new ReadAllQuery(Person.class);
       q.setJPQLString("SELECT OBJECT(p) FROM Person p");
       q.addArgument("1");
       q.addArgument("3");
       List args = new ArrayList();
       args.add(activityCode);
       q.cacheQueryResults();
       q.cacheStatement();
       q.setQueryResultsCachePolicy(new QueryResultsCachePolicy(new
TimeToLiveCacheInvalidationPolicy(60000));
       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:

http://wiki.eclipse.org/EclipseLink/Examples/JPA/ORMQueries#A_Simple_ReadAllQuery_Using_JPQL




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
416-737-9024
_______________________________________________


Back to the top