I believe this question popped up on this list a couple of days ago as well, but I couldn't find it anymore.
Anyway, ReadAllQueries always hit the database, because they need to determine what records are to be returned (there might be different ones in the database compared to when your query was last executed). When records are returned that are already stored in the cache, it will return the corresponding cached objects so there is some optimization there.
----- Oorspronkelijk bericht -----
Verzonden: Donderdag 20 mei 2010 00:11:39 GMT +01:00 Amsterdam / Berlijn / Bern / Rome / St!
ockholm / Wenen
Onderwerp: [eclipselink-users] Caching read-all queries
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?
eclipselink-users mailing list