You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "gonzalad (JIRA)" <ji...@apache.org> on 2013/01/23 15:56:13 UTC

[jira] [Commented] (OPENJPA-2327) QueryCache as hint

    [ https://issues.apache.org/jira/browse/OPENJPA-2327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13560732#comment-13560732 ] 

gonzalad commented on OPENJPA-2327:
-----------------------------------

Wouldn't it be nice to use javax.persistence.cache.retrieveMode (or javax.persistence.cache.storeMode) as a hint to enable query caching ?

And to introduce this in JPA spec ?

Perhaps I'm missing sthing here and there's going to be a collision with another function already activated by those hints though.

                
> QueryCache as hint
> ------------------
>
>                 Key: OPENJPA-2327
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2327
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: gonzalad
>
> Provide a way to enable query cache as a query hint.
> This would facilitate writing portable JPA applications.
> For the time being, with OpenJPA, we need to execute the following code to cache the query :
> {code:java}
> OpenJPAEntityManager oem = ((OpenJPAQuery<?>) query).getEntityManager();
> OpenJPAEntityManagerFactory oemf = oem.getEntityManagerFactory();
> QueryResultCache qcache = oemf.getQueryResultCache();
> qcache.pin(query);
> {code}
> It would be easier if JPA provided a query hint like :
> {code:java}
> query.setHint("openjpa.cacheable", cache);
> {code}
> This would even enable us to use it in a NamedQuery declaration :
> {code:java}
> @NamedQuery(name = "Civilite.findAll",
>     query = "SELECT c FROM Civilite c", 
>     hints = @QueryHint(name = "openjpa.cacheable", value = "true"))
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira