Neel
Neel

Reputation: 2100

What is the technique to configure JPA query cache so that it avoids multiple database hits when query returns no results?

I am using EclipseLink's implementation of JPA to query a table using a non-primary key field.

To cache results returned by this query, I have configured Query Results cache.

I have also annotated my entity with QUERY_RESULTS_CACHE_IGNORE_NULL set to true, so that it allows insert of new rows as per this javadoc.

However, when no results are returned, firing the query misses the cache. Is there a configuration on query results cache either in JPA or Eclipselink which causes a cache hit even when no results are returned?

This behavior seems to be conflicting with the QUERY_RESULTS_CACHE_IGNORE_NULL flag. I expect the cache to be flushed once there is a subsequent write, followed by the query being fired again.

Upvotes: 0

Views: 91

Answers (0)

Related Questions