Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-13005

Spring Data 2 - "JPA style" and working with multiple Ignite instances on same JVM

Log workAgile BoardRank to TopRank to BottomAttach filesAttach ScreenshotBulk Copy AttachmentsBulk Move AttachmentsVotersWatch issueWatchersCreate sub-taskConvert to sub-taskLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.7.6, 2.8.1
    • 2.9
    • spring
    • Hide
      Spring Data 2 - "JPA style" and working with multiple Ignite instances on same JVM
          
          Support multiple Ignite instances on same JVM (@RepositoryConfig).
          Support query tuning parameters in @Query annotation
          Support projections
          Support Page and Stream responses
          Support Sql Fields Query resultset transformation into the domain entity
          Support named parameters (:myParam) into SQL queries, declared using @Param("myParam")
          Support advanced parameter binding and SpEL expressions into SQL queries:
          Template variables:
            #entityName - the simple class name of the domain entity
          Method parameter expressions: Parameters are exposed for indexed access ([0] is the first query method's param) or via the name declared using @Param. The actual SpEL expression binding is triggered by ?#. Example: ?#{[0] or ?#{#myParamName}
          Advanced SpEL expressions: While advanced parameter binding is a very useful feature, the real power of SpEL stems from the fact, that the expressions can refer to framework abstractions or other application components through SpEL EvaluationContext extension model.
          Support SpEL expressions into Text queries (TextQuery).
      Show
      Spring Data 2 - "JPA style" and working with multiple Ignite instances on same JVM          Support multiple Ignite instances on same JVM (@RepositoryConfig).     Support query tuning parameters in @Query annotation     Support projections     Support Page and Stream responses     Support Sql Fields Query resultset transformation into the domain entity     Support named parameters (:myParam) into SQL queries, declared using @Param("myParam")     Support advanced parameter binding and SpEL expressions into SQL queries:     Template variables:       #entityName - the simple class name of the domain entity     Method parameter expressions: Parameters are exposed for indexed access ([0] is the first query method's param) or via the name declared using @Param. The actual SpEL expression binding is triggered by ?#. Example: ?#{[0] or ?#{#myParamName}     Advanced SpEL expressions: While advanced parameter binding is a very useful feature, the real power of SpEL stems from the fact, that the expressions can refer to framework abstractions or other application components through SpEL EvaluationContext extension model.     Support SpEL expressions into Text queries (TextQuery).
    • Docs Required

    Description

      I have it working for Spring Data 2 (2.7.6, 2.8.1) module with some interesting improvements.

      Code is 100% compatible with previous versions. https://github.com/hawkore/ignite-hk/tree/master/modules/spring-data-2.0

      • Supports multiple ignite instances on same JVM (@RepositoryConfig).
      • Supports query tuning parameters in @Query annotation
      • Supports projections
      • Supports Page and Stream responses
      • Supports Sql Fields Query resultset transformation into the domain entity
      • Supports named parameters (:myParam) into SQL queries, declared using @Param("myParam")
      • Supports advanced parameter binding and SpEL expressions into SQL queries:
        • Template variables:
          • #entityName - the simple class name of the domain entity
        • Method parameter expressions: Parameters are exposed for indexed access ([0] is the first query method's param) or via the name declared using @Param. The actual SpEL expression binding is triggered by ?#. Example: ?#{[0] or ?#{#myParamName}
        • Advanced SpEL expressions: While advanced parameter binding is a very useful feature, the real power of SpEL stems from the fact, that the expressions can refer to framework abstractions or other application components through SpEL EvaluationContext extension model.
      • Supports SpEL expressions into Text queries (TextQuery).

      Some examples:

      // Spring Data Repositories using different ignite instances on same JVM
      @RepositoryConfig(igniteInstance = "FLIGHTS_BBDD", cacheName = "ROUTES")
      public interface FlightRouteRepository extends IgniteRepository<Route, String> {
      
      ...
      
      }
      
      @RepositoryConfig(igniteInstance = "GEO_BBDD", cacheName = "POIS")
      public interface PoiRepository extends IgniteRepository<Poi, String> {
      
      ...
      
      }
      
      // named parameter
      @Query(value = "SELECT * from #{#entityName} where email = :email")
      User searchUserByEmail(@Param("email") String email);
      
      // indexed parameters
      @Query(value = "SELECT * from #{#entityName} where country = ?#{[0] and city = ?#{[1]}")
      List<User> searchUsersByCity(@Param("country") String country, @Param("city") String city, Pageable pageable);
      
      // ordered method parameters
      @Query(value = "SELECT * from #{#entityName} where email = ?")
      User searchUserByEmail(String email);
      
      // Advanced SpEL expressions
      @Query(value = "SELECT * from #{#entityName} where uuidCity = ?#{mySpELFunctionsBean.cityNameToUUID(#city)}")
      List<User> searchUsersByCity(@Param("city") String city, Pageable pageable);
      
      // textQuery - evaluated SpEL named parameter
      @Query(textQuery = true, value = "email: #{#email}")
      User searchUserByEmail(@Param("email") String email);
      
      // textQuery - evaluated SpEL named parameter
      @Query(textQuery = true, value = "#{#textToSearch}")
      List<User> searchUsersByText(@Param("textToSearch") String text, Pageable pageable);
      
      // textQuery - evaluated SpEL indexed parameter
      @Query(textQuery = true, value = "#{[0]}")
      List<User> searchUsersByText(String textToSearch, Pageable pageable);
      
      // Static Projection
      @Query(value =
                     "SELECT DISTINCT m.id, m.name, m.logos FROM #{#entityName} e USE INDEX (ORIGIN_IDX) INNER JOIN \"flightMerchants\".Merchant m ON m"
                         + "._key=e"
                         + ".merchant WHERE e.origin = :origin and e.disabled = :disabled GROUP BY m.id, m.name, m.logos ORDER BY m.name")
      List<AProjection> searchMerchantsByOrigin(@Param("origin") String origin, @Param("disabled") boolean disabled);
      
      // Dynamic Projection
      @Query(value =
                     "SELECT DISTINCT m.id, m.name, m.logos FROM #{#entityName} e USE INDEX (ORIGIN_IDX) INNER JOIN \"flightMerchants\".Merchant m ON m"
                         + "._key=e"
                         + ".merchant WHERE e.origin = :origin and e.disabled = :disabled GROUP BY m.id, m.name, m.logos ORDER BY m.name")
      <P> List<P> searchMerchantsByOrigin(Class<P> projection, @Param("origin") String origin, @Param("disabled") boolean disabled);
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            mnusan Manuel Núñez Assign to me
            mnusan Manuel Núñez
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0h
              0h
              Logged:
              Time Spent - 20m
              20m

              Slack

                Issue deployment