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

John D. Ament commented on DELTASPIKE-1157:
-------------------------------------------

Hi [~am],

Great use case.  Definitely something we can tackle.  Which way is preferable?

1. We add a method argument @QueryHints to represent a map of hints that should 
be passed in.
2. You can still use @Query, but it can rely on the existing method expression 
support.
3. We add a @QueryHints annotation to the method, to represent your hints.

> Repository.findBy methods do not allow an override to add query hints.
> ----------------------------------------------------------------------
>
>                 Key: DELTASPIKE-1157
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-1157
>             Project: DeltaSpike
>          Issue Type: New Feature
>          Components: Data-Module
>    Affects Versions: 1.5.3
>            Reporter: Amita Mehta
>            Assignee: John D. Ament
>
> We need a way to to add hints or a property override to the findBy methods 
> for the primary key to prevent reading stale data .
> We tried overriding the findBy with query hints but these are ignored by the 
> DelatSpike Data Module EntityRepositoryHandler .
> {code}
>     @Override
>     @Query(hints = {@QueryHint(name = "javax.persistence.cache.retrieveMode",
>         value = "BYPASS"), @QueryHint(name = "eclipselink.refresh",
>             value = "TRUE")})
>     public ENTITY findBy(PK primaryKey);
> {code}
> The only thing that works is creating a custom query in the repository that 
> uses override properties –
> {code}
>    public AgentDE findByPK(final String primaryKey) {
>         final Map<String, Object> properties = new HashMap<String, Object>();
>         properties.put("QueryHints.CACHE_USAGE", CacheUsage.DoNotCheckCache);
>         properties.put("eclipselink.refresh", "true");
>         
> entityManager().getEntityManagerFactory().getCache().evict(entityClass(), 
> primaryKey);
>         entityManager().clear();
>         return entityManager().find(entityClass(), primaryKey, properties);
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to