Class DynamicJpaRepositoryQuery

java.lang.Object
org.springframework.data.jpa.repository.query.AbstractJpaQuery
com.joutvhu.dynamic.jpa.query.DynamicJpaRepositoryQuery
All Implemented Interfaces:
org.springframework.data.repository.query.RepositoryQuery

public class DynamicJpaRepositoryQuery extends org.springframework.data.jpa.repository.query.AbstractJpaQuery
RepositoryQuery implementation that inspects a DynamicJpaQueryMethod for the existence of an DynamicQuery annotation and creates a JPA DynamicQuery from it.
Since:
2.x.1
  • Constructor Summary

    Constructors
    Constructor
    Description
    DynamicJpaRepositoryQuery(DynamicJpaQueryMethod method, jakarta.persistence.EntityManager em, org.springframework.data.jpa.repository.QueryRewriter queryRewriter, org.springframework.data.repository.query.QueryMethodEvaluationContextProvider evaluationContextProvider)
    Creates a new DynamicJpaRepositoryQuery from the given AbstractJpaQuery.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
    buildQuery(com.joutvhu.dynamic.commons.DynamicQueryTemplate template, org.springframework.data.jpa.repository.query.JpaParametersParameterAccessor accessor)
     
    protected org.springframework.data.jpa.repository.query.ParameterBinder
     
    protected jakarta.persistence.Query
    createJpaQuery(String queryString, org.springframework.data.domain.Sort sort, org.springframework.data.domain.Pageable pageable, org.springframework.data.repository.query.ReturnedType returnedType)
    Creates an appropriate JPA query from an EntityManager according to the current DynamicJpaRepositoryQuery type.
    protected jakarta.persistence.Query
    doCreateCountQuery(org.springframework.data.jpa.repository.query.JpaParametersParameterAccessor accessor)
     
    protected jakarta.persistence.Query
    doCreateQuery(org.springframework.data.jpa.repository.query.JpaParametersParameterAccessor accessor)
     
    protected String
    potentiallyRewriteQuery(String originalQuery, org.springframework.data.domain.Sort sort, org.springframework.data.domain.Pageable pageable)
    Use the QueryRewriter, potentially rewrite the query, using relevant Sort and Pageable information.
    setAccessor(org.springframework.data.jpa.repository.query.JpaParametersParameterAccessor accessor)
     

    Methods inherited from class org.springframework.data.jpa.repository.query.AbstractJpaQuery

    applyHints, applyQueryHint, createCountQuery, createQuery, execute, getEntityManager, getExecution, getMetamodel, getQueryMethod, getTypeToRead

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DynamicJpaRepositoryQuery

      public DynamicJpaRepositoryQuery(DynamicJpaQueryMethod method, jakarta.persistence.EntityManager em, org.springframework.data.jpa.repository.QueryRewriter queryRewriter, org.springframework.data.repository.query.QueryMethodEvaluationContextProvider evaluationContextProvider)
      Creates a new DynamicJpaRepositoryQuery from the given AbstractJpaQuery.
      Parameters:
      method - DynamicJpaQueryMethod
      em - EntityManager
      evaluationContextProvider - QueryMethodEvaluationContextProvider
  • Method Details

    • buildQuery

      protected String buildQuery(com.joutvhu.dynamic.commons.DynamicQueryTemplate template, org.springframework.data.jpa.repository.query.JpaParametersParameterAccessor accessor)
    • createBinder

      protected org.springframework.data.jpa.repository.query.ParameterBinder createBinder()
      Overrides:
      createBinder in class org.springframework.data.jpa.repository.query.AbstractJpaQuery
    • setAccessor

      protected DynamicBasedStringQuery setAccessor(org.springframework.data.jpa.repository.query.JpaParametersParameterAccessor accessor)
    • doCreateQuery

      protected jakarta.persistence.Query doCreateQuery(org.springframework.data.jpa.repository.query.JpaParametersParameterAccessor accessor)
      Specified by:
      doCreateQuery in class org.springframework.data.jpa.repository.query.AbstractJpaQuery
    • doCreateCountQuery

      protected jakarta.persistence.Query doCreateCountQuery(org.springframework.data.jpa.repository.query.JpaParametersParameterAccessor accessor)
      Specified by:
      doCreateCountQuery in class org.springframework.data.jpa.repository.query.AbstractJpaQuery
    • createJpaQuery

      protected jakarta.persistence.Query createJpaQuery(String queryString, org.springframework.data.domain.Sort sort, @Nullable org.springframework.data.domain.Pageable pageable, org.springframework.data.repository.query.ReturnedType returnedType)
      Creates an appropriate JPA query from an EntityManager according to the current DynamicJpaRepositoryQuery type.
      Parameters:
      queryString - is query
      returnedType - of method
      Returns:
      a Query
    • potentiallyRewriteQuery

      protected String potentiallyRewriteQuery(String originalQuery, org.springframework.data.domain.Sort sort, @Nullable org.springframework.data.domain.Pageable pageable)
      Use the QueryRewriter, potentially rewrite the query, using relevant Sort and Pageable information.