Hello, is it possible to run queries that don't return an object against the cache?
For example a query like this that retrieves the lastnames from all Employees:
SELECT e.lastname FROM Employee e
Assume the table is cached with a full cache and a query was executed before so the cache should be fully populated. When using a ReportQuery i get an exception that report queries can not be used with CheckCacheOnly, when i use a ReadAllQuery the query returns objects instead of only the lastname values.
No, ReportQuery (which is used for queries returning non-entities) will only hit the database. The reason is likely because the cache is an object cache, and report queries just were over looked as in-memory querying was implemented - it might have just been assumed the entire object would be wanted since it is available. A feature could be filed to get EclipseLink to extract the fields from objects after running the query in-memory, but It might be more efficient to have the application run a query for the entities and then just pull the data from the returned entities directly.