Uploaded image for project: 'DeltaSpike'
  1. DeltaSpike
  2. DELTASPIKE-1157

Repository.findBy methods do not allow an override to add query hints.

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.3
    • 1.7.0
    • Data-Module
    • None

    Description

      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 .

          @Override
          @Query(hints = {@QueryHint(name = "javax.persistence.cache.retrieveMode",
              value = "BYPASS"), @QueryHint(name = "eclipselink.refresh",
                  value = "TRUE")})
          public ENTITY findBy(PK primaryKey);
      

      The only thing that works is creating a custom query in the repository that uses override properties –

         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);
      
          }
      

      Attachments

        Activity

          People

            johndament John D. Ament
            am Amita Mehta
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: