Uploaded image for project: 'Spring Data GemFire'
  1. Spring Data GemFire
  2. SGF-713

Override generated OQL from Repository query methods

    XMLWordPrintable

    Details

      Description

      We have a scenario where we need to override the region-name at runtime. Based on replies from stackoverflow, we were able to override the getRegionName in a custom Gemfire Template after overriding the repositoryBaseClass.

      https://stackoverflow.com/questions/45742856/sdg-override-generated-queries

      While this works for the queries based on SimpleGemfireRepository, we're unable to override the region-names in the the findBy/@Query repository methods. Based on code-walkthrough, we have identified the StringBasedGemfireGemfireRepositoryQuery class - execute method where post the queryCreation, we will be able to do a string-replace based on custom logic.

      Is there a possibility to have a method-hook (say customizeGeneratedQuery()) which can be called and there is no default behavior. But custom implementations can override this method to accomplish the feature. I'm looking at an option to enable bean-injection as prototype. But if there is an alternative/best-practice, that'll be interesting.

      The other way, to create our own Query implementation causes a lot of code duplication and forces us to use the org.springframework package in our code as few methods have default access.

        Attachments

        1. PartTreeGemfireRepositoryQuery.java
          4 kB
          JEBUSELWYN MARTIN
        2. QueryCustomizer.java
          0.7 kB
          JEBUSELWYN MARTIN
        3. StringBasedGemfireRepositoryQuery.java
          9 kB
          JEBUSELWYN MARTIN

          Activity

            People

            Assignee:
            jblum John Blum
            Reporter:
            jebuselwyn JEBUSELWYN MARTIN
            Last updater:
            John Blum John Blum
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: