I am using EclipseLink 2.5.0 I am trying to achieve following.
- Query an object using non-key filters.
- If result is not null, it should be cached, and future queries with same filter values should not go to data base.
- If no result is found, the result should not be cached and future queries with same filter values should go to data base.
I think, I should be able to achieve it with eclipselink.query-results-cache.ignore-null
hint, but if I include following
<hint name="eclipselink.query-results-cache.ignore-null" value="true"/>
No result is being cached. And if I am including following
<hint name="eclipselink.query-results-cache" value="true"/>
Even 'none'(no record found) is being cached. My complete named query looks like following
<named-query name="find.Employee.findEmployeeByPlace">
<description>
Find employee by place.
</description>
<query><![CDATA[
select e
from Employee e
where e.place = :place
]]></query>
<!--<hint name="eclipselink.query-results-cache" value="true"/>-->
<hint name="eclipselink.query-results-cache.ignore-null" value="true"/>
</named-query>
My findings seems to be opposite of How to get Glassfish/EclipseLink/JPA to cache entityManager.find results that return null