Java 类org.springframework.data.repository.query.EvaluationContextProvider 实例源码

项目:spring-data-jdbc    文件:JdbcQueryLookupStrategy.java   
/**
 * Creates a {@link QueryLookupStrategy} for the given {@link EntityManager}
 * and {@link Key}.
 *
 * @param em                        must not be {@literal null}.
 * @param key                       may be {@literal null}.
 * @param extractor                 must not be {@literal null}.
 * @param evaluationContextProvider must not be {@literal null}.
 * @return
 */
public static QueryLookupStrategy create(Key key, EvaluationContextProvider evaluationContextProvider,
                                         SqlGenerator generator, NamedParameterJdbcTemplate template, RowMapper rowMapper,
                                         TableDescription tableDescription) {

    Assert.notNull(evaluationContextProvider, "EvaluationContextProvider must not be null!");

    switch (key != null ? key : Key.CREATE_IF_NOT_FOUND) {
        case CREATE:
            return new CreateQueryLookupStrategy(generator, template, rowMapper, tableDescription);
        case USE_DECLARED_QUERY:
            return new DeclaredQueryLookupStrategy(generator, template, rowMapper, tableDescription);
        case CREATE_IF_NOT_FOUND:
            return new CreateIfNotFoundQueryLookupStrategy(generator, template, rowMapper, tableDescription);
        default:
            throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s!", key));
    }
}
项目:spring-data-ebean    文件:NativeEbeanQuery.java   
/**
 * Creates a new {@link NativeEbeanQuery} encapsulating the query annotated on the given {@link EbeanQueryMethod}.
 *
 * @param method                    must not be {@literal null}.
 * @param ebeanServer               must not be {@literal null}.
 * @param queryString               must not be {@literal null} or empty.
 * @param evaluationContextProvider
 */
public NativeEbeanQuery(EbeanQueryMethod method, EbeanServer ebeanServer, String queryString,
                        EvaluationContextProvider evaluationContextProvider, SpelExpressionParser parser) {

  super(method, ebeanServer, queryString, evaluationContextProvider, parser);

  Parameters<?, ?> parameters = method.getParameters();
  boolean hasPagingOrSortingParameter = parameters.hasPageableParameter() || parameters.hasSortParameter();
  boolean containsPageableOrSortInQueryExpression = queryString.contains("#pageable")
      || queryString.contains("#sort");

  if (hasPagingOrSortingParameter && !containsPageableOrSortInQueryExpression) {
    throw new InvalidEbeanQueryMethodException(
        "Cannot use native queries with dynamic sorting and/or pagination in method " + method);
  }
}
项目:spring-data-ebean    文件:EbeanQueryLookupStrategy.java   
/**
 * Creates a {@link QueryLookupStrategy} for the given {@link EbeanServer} and {@link Key}.
 *
 * @param ebeanServer               must not be {@literal null}.
 * @param key                       may be {@literal null}.
 * @param evaluationContextProvider must not be {@literal null}.
 * @return
 */
public static QueryLookupStrategy create(EbeanServer ebeanServer, Key key,
                                         EvaluationContextProvider evaluationContextProvider) {

  Assert.notNull(ebeanServer, "EbeanServer must not be null!");
  Assert.notNull(evaluationContextProvider, "EvaluationContextProvider must not be null!");

  switch (key != null ? key : Key.CREATE_IF_NOT_FOUND) {
    case CREATE:
      return new CreateQueryLookupStrategy(ebeanServer);
    case USE_DECLARED_QUERY:
      return new DeclaredQueryLookupStrategy(ebeanServer, evaluationContextProvider);
    case CREATE_IF_NOT_FOUND:
      return new CreateIfNotFoundQueryLookupStrategy(ebeanServer, new CreateQueryLookupStrategy(ebeanServer),
          new DeclaredQueryLookupStrategy(ebeanServer, evaluationContextProvider));
    default:
      throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s!", key));
  }
}
项目:spring-data-ebean    文件:NativeEbeanUpdate.java   
/**
 * Creates a new {@link NativeEbeanUpdate} encapsulating the query annotated on the given {@link EbeanQueryMethod}.
 *
 * @param method                    must not be {@literal null}.
 * @param ebeanServer               must not be {@literal null}.
 * @param queryString               must not be {@literal null} or empty.
 * @param evaluationContextProvider
 */
public NativeEbeanUpdate(EbeanQueryMethod method, EbeanServer ebeanServer, String queryString,
                         EvaluationContextProvider evaluationContextProvider, SpelExpressionParser parser) {

  super(method, ebeanServer, queryString, evaluationContextProvider, parser);

  Parameters<?, ?> parameters = method.getParameters();
  boolean hasPagingOrSortingParameter = parameters.hasPageableParameter() || parameters.hasSortParameter();
  boolean containsPageableOrSortInQueryExpression = queryString.contains("#pageable")
      || queryString.contains("#sort");

  if (hasPagingOrSortingParameter && !containsPageableOrSortInQueryExpression) {
    throw new InvalidEbeanQueryMethodException(
        "Cannot use native queries with dynamic sorting and/or pagination in method " + method);
  }
}
项目:spring-data-mybatis    文件:MybatisQueryLookupStrategy.java   
public static QueryLookupStrategy create(
        MybatisMappingContext context,
        SqlSessionTemplate sqlSessionTemplate,
        Dialect dialect,
        Key key,
        EvaluationContextProvider evaluationContextProvider) {
    Assert.notNull(evaluationContextProvider, "EvaluationContextProvider must not be null!");
    switch (key != null ? key : Key.CREATE_IF_NOT_FOUND) {
        case CREATE:
            return new CreateQueryLookupStrategy(context, sqlSessionTemplate, dialect);
        case USE_DECLARED_QUERY:
            return new DeclaredQueryLookupStrategy(sqlSessionTemplate, evaluationContextProvider);
        case CREATE_IF_NOT_FOUND:
            return new CreateIfNotFoundQueryLookupStrategy(
                    new CreateQueryLookupStrategy(context, sqlSessionTemplate, dialect),
                    new DeclaredQueryLookupStrategy(sqlSessionTemplate, evaluationContextProvider));
        default:
            throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s!", key));
    }
}
项目:spring-data-keyvalue    文件:KeyValueRepositoryFactory.java   
@Override
@SuppressWarnings("unchecked")
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory,
        NamedQueries namedQueries) {

    QueryMethod queryMethod = new QueryMethod(method, metadata, factory);

    Constructor<? extends KeyValuePartTreeQuery> constructor = (Constructor<? extends KeyValuePartTreeQuery>) ClassUtils
            .getConstructorIfAvailable(this.repositoryQueryType, QueryMethod.class, EvaluationContextProvider.class,
                    KeyValueOperations.class, Class.class);

    Assert.state(constructor != null,
            String.format(
                    "Constructor %s(QueryMethod, EvaluationContextProvider, KeyValueOperations, Class) not available!",
                    ClassUtils.getShortName(this.repositoryQueryType)));

    return BeanUtils.instantiateClass(constructor, queryMethod, evaluationContextProvider, this.keyValueOperations,
            this.queryCreator);
}
项目:tasfe-framework    文件:GenericJpaRepositoryFactory.java   
@Override
protected QueryLookupStrategy getQueryLookupStrategy(QueryLookupStrategy.Key key, EvaluationContextProvider evaluationContextProvider) {
    QueryLookupStrategy queryLookupStrategy = GenericQueryLookupStrategy.create(entityManager ,
            sqlSessionTemplate , key , extractor , evaluationContextProvider) ;

    return queryLookupStrategy  ;
}
项目:tasfe-framework    文件:GenericQueryLookupStrategy.java   
public GenericQueryLookupStrategy(EntityManager entityManager, SqlSessionTemplate sqlSessionTemplate  ,
                                  Key key, QueryExtractor extractor, EvaluationContextProvider evaluationContextProvider) {
    this.jpaQueryLookupStrategy = JpaQueryLookupStrategy.create(entityManager, key, extractor, evaluationContextProvider);
    this.extractor = extractor;
    this.entityManager = entityManager;
    this.sqlSessionTemplate = sqlSessionTemplate ;
}
项目:spring-data-ebean    文件:AbstractStringBasedEbeanQuery.java   
/**
 * Creates a new {@link AbstractStringBasedEbeanQuery} from the given {@link EbeanQueryMethod}, {@link io.ebean.EbeanServer} and
 * query {@link String}.
 *
 * @param method                    must not be {@literal null}.
 * @param ebeanServer               must not be {@literal null}.
 * @param queryString               must not be {@literal null}.
 * @param evaluationContextProvider must not be {@literal null}.
 * @param parser                    must not be {@literal null}.
 */
public AbstractStringBasedEbeanQuery(EbeanQueryMethod method, EbeanServer ebeanServer, String queryString,
                                     EvaluationContextProvider evaluationContextProvider, SpelExpressionParser parser) {

  super(method, ebeanServer);

  Assert.hasText(queryString, "Query string must not be null or empty!");
  Assert.notNull(evaluationContextProvider, "ExpressionEvaluationContextProvider must not be null!");
  Assert.notNull(parser, "Parser must not be null or empty!");

  this.evaluationContextProvider = evaluationContextProvider;
  this.query = new ExpressionBasedStringQuery(queryString, method.getEntityInformation(), parser);
  this.parser = parser;
}
项目:spring-data-ebean    文件:SpelExpressionStringQueryParameterBinder.java   
/**
 * Creates a new {@link SpelExpressionStringQueryParameterBinder}.
 *
 * @param parameters                must not be {@literal null}
 * @param values                    must not be {@literal null}
 * @param query                     must not be {@literal null}
 * @param evaluationContextProvider must not be {@literal null}
 * @param parser                    must not be {@literal null}
 */
public SpelExpressionStringQueryParameterBinder(DefaultParameters parameters, Object[] values, StringQuery query,
                                                EvaluationContextProvider evaluationContextProvider, SpelExpressionParser parser) {

  super(parameters, values, query);
  Assert.notNull(evaluationContextProvider, "EvaluationContextProvider must not be null!");
  Assert.notNull(parser, "SpelExpressionParser must not be null!");

  this.evaluationContextProvider = evaluationContextProvider;
  this.query = query;
  this.parser = parser;
}
项目:spring-data-jpa-extra    文件:TemplateQueryLookupStrategy.java   
public TemplateQueryLookupStrategy(EntityManager entityManager, Key key, QueryExtractor extractor,
        EvaluationContextProvider evaluationContextProvider) {
    this.jpaQueryLookupStrategy = JpaQueryLookupStrategy
            .create(entityManager, key, extractor, evaluationContextProvider);
    this.extractor = extractor;
    this.entityManager = entityManager;
}
项目:spring-vault    文件:VaultPartTreeQuery.java   
/**
 * Creates a new {@link VaultPartTreeQuery} for the given {@link QueryMethod},
 * {@link EvaluationContextProvider}, {@link KeyValueOperations} and query creator
 * type.
 *
 * @param queryMethod must not be {@literal null}.
 * @param evaluationContextProvider must not be {@literal null}.
 * @param keyValueOperations must not be {@literal null}.
 * @param queryCreator must not be {@literal null}.
 */
@SuppressWarnings("unchecked")
public VaultPartTreeQuery(QueryMethod queryMethod,
        EvaluationContextProvider evaluationContextProvider,
        KeyValueOperations keyValueOperations,
        Class<? extends AbstractQueryCreator<?, ?>> queryCreator) {

    super(queryMethod, evaluationContextProvider, keyValueOperations,
            new VaultQueryCreatorFactory(
                    (MappingContext) keyValueOperations.getMappingContext()));
}
项目:mongodb-aggregate-query-support    文件:AggregateQuerySupportingRepositoryFactory.java   
@Override
public QueryLookupStrategy getQueryLookupStrategy(QueryLookupStrategy.Key key,
                                                  EvaluationContextProvider evaluationContextProvider) {

  QueryLookupStrategy parentQueryLookupStrategy = super.getQueryLookupStrategy(key, evaluationContextProvider);
  return new AggregateQueryLookupStrategy(parentQueryLookupStrategy);
}
项目:genericdao    文件:GenericJpaRepositoryFactory.java   
@Override
protected QueryLookupStrategy getQueryLookupStrategy(QueryLookupStrategy.Key key, EvaluationContextProvider evaluationContextProvider) {
    QueryLookupStrategy queryLookupStrategy = GenericQueryLookupStrategy.create(entityManager ,
            sqlSessionTemplate , key , extractor , evaluationContextProvider) ;

    return queryLookupStrategy  ;
}
项目:genericdao    文件:GenericQueryLookupStrategy.java   
public GenericQueryLookupStrategy(EntityManager entityManager, SqlSessionTemplate sqlSessionTemplate  ,
                                  Key key, QueryExtractor extractor, EvaluationContextProvider evaluationContextProvider) {
    this.jpaQueryLookupStrategy = JpaQueryLookupStrategy.create(entityManager, key, extractor, evaluationContextProvider);
    this.extractor = extractor;
    this.entityManager = entityManager;
    this.sqlSessionTemplate = sqlSessionTemplate ;
}
项目:ignite    文件:IgniteRepositoryFactory.java   
/** {@inheritDoc} */
@Override protected QueryLookupStrategy getQueryLookupStrategy(final QueryLookupStrategy.Key key,
    EvaluationContextProvider evaluationCtxProvider) {

    return new QueryLookupStrategy() {
        @Override public RepositoryQuery resolveQuery(final Method mtd, final RepositoryMetadata metadata,
            final ProjectionFactory factory, NamedQueries namedQueries) {

            final Query annotation = mtd.getAnnotation(Query.class);

            if (annotation != null) {
                String qryStr = annotation.value();

                if (key != Key.CREATE && StringUtils.hasText(qryStr))
                    return new IgniteRepositoryQuery(metadata,
                        new IgniteQuery(qryStr, isFieldQuery(qryStr), IgniteQueryGenerator.getOptions(mtd)),
                        mtd, factory, ignite.getOrCreateCache(repoToCache.get(metadata.getRepositoryInterface())));
            }

            if (key == QueryLookupStrategy.Key.USE_DECLARED_QUERY)
                throw new IllegalStateException("To use QueryLookupStrategy.Key.USE_DECLARED_QUERY, pass " +
                    "a query string via org.apache.ignite.springdata.repository.config.Query annotation.");

            return new IgniteRepositoryQuery(metadata, IgniteQueryGenerator.generateSql(mtd, metadata), mtd,
                factory, ignite.getOrCreateCache(repoToCache.get(metadata.getRepositoryInterface())));
        }
    };
}
项目:spring-data-keyvalue    文件:KeyValuePartTreeQuery.java   
/**
 * Creates a new {@link KeyValuePartTreeQuery} for the given {@link QueryMethod}, {@link EvaluationContextProvider},
 * {@link KeyValueOperations} using the given {@link QueryCreatorFactory} producing the {@link AbstractQueryCreator}
 * in charge of altering the query.
 *
 * @param queryMethod must not be {@literal null}.
 * @param evaluationContextProvider must not be {@literal null}.
 * @param keyValueOperations must not be {@literal null}.
 * @param queryCreatorFactory must not be {@literal null}.
 * @since 2.0
 */
public KeyValuePartTreeQuery(QueryMethod queryMethod, EvaluationContextProvider evaluationContextProvider,
        KeyValueOperations keyValueOperations, QueryCreatorFactory queryCreatorFactory) {

    Assert.notNull(queryMethod, "Query method must not be null!");
    Assert.notNull(evaluationContextProvider, "EvaluationContextprovider must not be null!");
    Assert.notNull(keyValueOperations, "KeyValueOperations must not be null!");
    Assert.notNull(queryCreatorFactory, "QueryCreatorFactory type must not be null!");

    this.queryMethod = queryMethod;
    this.keyValueOperations = keyValueOperations;
    this.evaluationContextProvider = evaluationContextProvider;
    this.queryCreatorFactory = queryCreatorFactory;
}
项目:spring-data-keyvalue    文件:KeyValueRepositoryFactory.java   
/**
 * @param key
 * @param evaluationContextProvider
 * @param keyValueOperations
 * @param queryCreator
 * @since 1.1
 */
public KeyValueQueryLookupStrategy(@Nullable Key key, EvaluationContextProvider evaluationContextProvider,
        KeyValueOperations keyValueOperations, Class<? extends AbstractQueryCreator<?, ?>> queryCreator,
        Class<? extends RepositoryQuery> repositoryQueryType) {

    Assert.notNull(evaluationContextProvider, "EvaluationContextProvider must not be null!");
    Assert.notNull(keyValueOperations, "KeyValueOperations must not be null!");
    Assert.notNull(queryCreator, "Query creator type must not be null!");
    Assert.notNull(repositoryQueryType, "RepositoryQueryType type must not be null!");

    this.evaluationContextProvider = evaluationContextProvider;
    this.keyValueOperations = keyValueOperations;
    this.queryCreator = queryCreator;
    this.repositoryQueryType = repositoryQueryType;
}
项目:spring-data-jdbc    文件:JdbcRepositoryFactory.java   
@Override
protected QueryLookupStrategy getQueryLookupStrategy(Key key, EvaluationContextProvider evaluationContextProvider) {

    return JdbcQueryLookupStrategy.create(key, evaluationContextProvider, generator, template, rowMapper, tableDescription);
}
项目:spring-data-documentdb    文件:DocumentDbRepositoryFactory.java   
@Override
protected QueryLookupStrategy getQueryLookupStrategy(QueryLookupStrategy.Key key,
                                                     EvaluationContextProvider evaluationContextProvider) {
    return new DocumentDbQueryLookupStrategy(dbOperations, evaluationContextProvider);
}
项目:spring-data-documentdb    文件:DocumentDbRepositoryFactory.java   
public DocumentDbQueryLookupStrategy(DocumentDbOperations operations, EvaluationContextProvider provider) {
    this.dbOperations = operations;
}
项目:tasfe-framework    文件:GenericQueryLookupStrategy.java   
public static QueryLookupStrategy create(EntityManager entityManager, SqlSessionTemplate sqlSessionTemplate  ,
                                         Key key, QueryExtractor extractor, EvaluationContextProvider evaluationContextProvider) {
    return new GenericQueryLookupStrategy(entityManager , sqlSessionTemplate ,
            key , extractor , evaluationContextProvider);
}
项目:spring-data-snowdrop    文件:SnowdropRepositoryFactory.java   
@Override
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(QueryLookupStrategy.Key key, EvaluationContextProvider evaluationContextProvider) {
    return Optional.of(new SnowdropQueryLookupStrategy());
}
项目:spring-data-snowdrop    文件:JpaWithSnowdropRepositoryFactory.java   
@Override
public void setEvaluationContextProvider(EvaluationContextProvider evaluationContextProvider) {
    super.setEvaluationContextProvider(evaluationContextProvider);
    snowdropRepositoryFactory.setEvaluationContextProvider(evaluationContextProvider);
}
项目:spring-data-jdbc-template    文件:JdbcTemplateRepositoryFactoryBean.java   
@Override
protected QueryLookupStrategy getQueryLookupStrategy(QueryLookupStrategy.Key key,
        EvaluationContextProvider evaluationContextProvider) {
    return new JdbcTemplateQueryLookupStrategy(beanFactory, configuration);
}
项目:spring-data-objectify    文件:ObjectifyRepositoryFactory.java   
@Override
protected QueryLookupStrategy getQueryLookupStrategy(Key key, EvaluationContextProvider evaluationContextProvider) {
    return new ObjectifyQueryLookupStrategy(key, evaluationContextProvider);
}
项目:spring-data-objectify    文件:ObjectifyQueryLookupStrategy.java   
public ObjectifyQueryLookupStrategy(Key key, EvaluationContextProvider evaluationContextProvider) {
}
项目:spring-data-ebean    文件:EbeanRepositoryFactory.java   
@Override
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(QueryLookupStrategy.Key key,
                                                               EvaluationContextProvider evaluationContextProvider) {
    return Optional.ofNullable(EbeanQueryLookupStrategy.create(ebeanServer, key, evaluationContextProvider));
}
项目:spring-data-mybatis    文件:MybatisQueryLookupStrategy.java   
private DeclaredQueryLookupStrategy(SqlSessionTemplate sqlSessionTemplate, EvaluationContextProvider evaluationContextProvider) {
    this.sqlSessionTemplate = sqlSessionTemplate;
    this.evaluationContextProvider = evaluationContextProvider;
}
项目:spring-data-mybatis    文件:SimpleMybatisQuery.java   
public SimpleMybatisQuery(SqlSessionTemplate sqlSessionTemplate, MybatisQueryMethod method, Query query, EvaluationContextProvider evaluationContextProvider, SpelExpressionParser parser) {
    super(sqlSessionTemplate, method);
}
项目:spring-data-mybatis    文件:MybatisRepositoryFactory.java   
@Override
protected QueryLookupStrategy getQueryLookupStrategy(Key key, EvaluationContextProvider evaluationContextProvider) {
    return MybatisQueryLookupStrategy.create(mappingContext, sessionTemplate, dialect, key, evaluationContextProvider);
}
项目:spring-data-jpa-extra    文件:GenericJpaRepositoryFactory.java   
@Override
protected QueryLookupStrategy getQueryLookupStrategy(QueryLookupStrategy.Key key,
        EvaluationContextProvider evaluationContextProvider) {
    return TemplateQueryLookupStrategy.create(entityManager, key, extractor, evaluationContextProvider);
}
项目:spring-data-jpa-extra    文件:TemplateQueryLookupStrategy.java   
public static QueryLookupStrategy create(EntityManager entityManager, Key key, QueryExtractor extractor,
        EvaluationContextProvider evaluationContextProvider) {
    return new TemplateQueryLookupStrategy(entityManager, key, extractor, evaluationContextProvider);
}
项目:mongodb-aggregate-query-support    文件:AggregateTestConfiguration.java   
@Bean
public EvaluationContextProvider evaluationContextProvider() {
  return new ExtensionAwareEvaluationContextProvider();
}
项目:strategy-spring-security-acl    文件:AclJpaRepositoryFactoryBean.java   
@Override
protected QueryLookupStrategy getQueryLookupStrategy(Key key,
    EvaluationContextProvider evaluationContextProvider) {
  return new AclQueryLookupStrategy(key, evaluationContextProvider);
}
项目:strategy-spring-security-acl    文件:AclJpaRepositoryFactoryBean.java   
public AclQueryLookupStrategy(Key key, EvaluationContextProvider evaluationContextProvider) {
  this.key = key;
  this.evaluationContextProvider = evaluationContextProvider;
}
项目:genericdao    文件:GenericQueryLookupStrategy.java   
public static QueryLookupStrategy create(EntityManager entityManager, SqlSessionTemplate sqlSessionTemplate  ,
                                         Key key, QueryExtractor extractor, EvaluationContextProvider evaluationContextProvider) {
    return new GenericQueryLookupStrategy(entityManager , sqlSessionTemplate ,
            key , extractor , evaluationContextProvider);
}
项目:spring-boot-starter-mybatis    文件:MyBatisRepositoryFactory.java   
@Override
protected QueryLookupStrategy getQueryLookupStrategy(final Key key, final EvaluationContextProvider evaluationContextProvider) {
    return new MyBatisQueryLookupStrategy(mapperProvider, key);
}
项目:spring-boot-starter-mybatis    文件:MyBatisRepositoryFactory.java   
@Override
protected QueryLookupStrategy getQueryLookupStrategy(final Key key, final EvaluationContextProvider evaluationContextProvider) {
    return new MyBatisQueryLookupStrategy(mapperProvider, key);
}
项目:ef-orm    文件:GqRepositoryFactory.java   
@Override
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(Key key, EvaluationContextProvider evaluationContextProvider) {
    return Optional.<QueryLookupStrategy> of(new GqQueryLookupStrategy(emf));
}