cache report queries

View: New views
2 Messages — Rating Filter:   Alert me  

cache report queries

by Jan Kriesten-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

is there a way to also cache report queries? E.g. I have something like this:

Query q = entityManager.createQuery( "select count(e) from User e" )
Long result = (Long) q.getSingleResult()

If I add a cache hint to the query

q.setHint( "eclipselink.cache-usage", "CheckCacheThenDatabase" )

I get a class cast exception (User -> Long), which is a bit puzzling.

Best regards, --- Jan.


_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Re: cache report queries

by James Sutherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The "cache-usage" is for the object cache, what you want is to use the query cache.

See,
http://www.eclipse.org/eclipselink/api/1.1.1/org/eclipse/persistence/config/QueryHints.html#QUERY_RESULTS_CACHE

It is odd that you can a User back though.  Probably log a bug for that, you should probably get an exception that states CheckCacheThenDatabase is an invalid option for a ReportQuery.

Jan Kriesten-2 wrote:
Hi,

is there a way to also cache report queries? E.g. I have something like this:

Query q = entityManager.createQuery( "select count(e) from User e" )
Long result = (Long) q.getSingleResult()

If I add a cache hint to the query

q.setHint( "eclipselink.cache-usage", "CheckCacheThenDatabase" )

I get a class cast exception (User -> Long), which is a bit puzzling.

Best regards, --- Jan.


_______________________________________________
eclipselink-users mailing list
eclipselink-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/eclipselink-users