org.springframework.data.repository.query.QueryLookupStrategy.Key Java Examples

The following examples show how to use org.springframework.data.repository.query.QueryLookupStrategy.Key. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EbeanQueryLookupStrategy.java    From spring-data-ebean with Apache License 2.0 6 votes vote down vote up
/**
 * 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,
                                         QueryMethodEvaluationContextProvider 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));
    }
}
 
Example #2
Source File: MybatisQueryLookupStrategy.java    From spring-data-mybatis with Apache License 2.0 6 votes vote down vote up
public static QueryLookupStrategy create(SqlSessionTemplate sqlSessionTemplate,
		Key key, QueryMethodEvaluationContextProvider evaluationContextProvider) {

	Assert.notNull(sqlSessionTemplate, "SqlSessionTemplate 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(sqlSessionTemplate);
	case USE_DECLARED_QUERY:
		return new DeclaredQueryLookupStrategy(sqlSessionTemplate,
				evaluationContextProvider);
	case CREATE_IF_NOT_FOUND:
		return new CreateIfNotFoundQueryLookupStrategy(sqlSessionTemplate,
				new CreateQueryLookupStrategy(sqlSessionTemplate),
				new DeclaredQueryLookupStrategy(sqlSessionTemplate,
						evaluationContextProvider));
	default:
		throw new IllegalArgumentException(
				String.format("Unsupported query lookup strategy %s!", key));
	}
}
 
Example #3
Source File: KeyValueRepositoryFactory.java    From spring-data-keyvalue with Apache License 2.0 6 votes vote down vote up
/**
 * @param key
 * @param evaluationContextProvider
 * @param keyValueOperations
 * @param queryCreator
 * @since 1.1
 */
public KeyValueQueryLookupStrategy(@Nullable Key key,
		QueryMethodEvaluationContextProvider 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;
}
 
Example #4
Source File: DynamoDBQueryLookupStrategy.java    From spring-data-dynamodb with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a {@link QueryLookupStrategy} for the given
 * {@link DynamoDBMapper} and {@link Key}.
 *
 * @param dynamoDBOperations
 * @param key
 * @return
 */
public static QueryLookupStrategy create(DynamoDBOperations dynamoDBOperations, Key key) {

	if (key == null) {
		return new CreateQueryLookupStrategy(dynamoDBOperations);
	}

	switch (key) {
	case CREATE:
		return new CreateQueryLookupStrategy(dynamoDBOperations);
	case USE_DECLARED_QUERY:
		throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s!", key));
	case CREATE_IF_NOT_FOUND:
		return new CreateIfNotFoundQueryLookupStrategy(dynamoDBOperations);
	default:
		throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s!", key));
	}
}
 
Example #5
Source File: ReactiveNeo4jRepositoryFactory.java    From sdn-rx with Apache License 2.0 5 votes vote down vote up
@Override
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(Key key,
	QueryMethodEvaluationContextProvider evaluationContextProvider) {

	return Optional
		.of(new ReactiveNeo4jQueryLookupStrategy(neo4jOperations, mappingContext, evaluationContextProvider));
}
 
Example #6
Source File: DatastoreRepositoryFactory.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Override
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(@Nullable Key key,
		QueryMethodEvaluationContextProvider evaluationContextProvider) {

	return Optional.of(new DatastoreQueryLookupStrategy(this.datastoreMappingContext,
			this.datastoreOperations,
			delegateContextProvider(evaluationContextProvider)));
}
 
Example #7
Source File: SpannerRepositoryFactory.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Override
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(@Nullable Key key,
		QueryMethodEvaluationContextProvider evaluationContextProvider) {

	return Optional.of(new SpannerQueryLookupStrategy(this.spannerMappingContext,
			this.spannerTemplate,
			delegateContextProvider(evaluationContextProvider), EXPRESSION_PARSER));
}
 
Example #8
Source File: MybatisRepositoryFactory.java    From spring-data-mybatis with Apache License 2.0 5 votes vote down vote up
@Override
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(Key key,
		QueryMethodEvaluationContextProvider evaluationContextProvider) {

	return Optional.of(MybatisQueryLookupStrategy.create(sqlSessionTemplate, key,
			evaluationContextProvider));
}
 
Example #9
Source File: Neo4jRepositoryFactory.java    From sdn-rx with Apache License 2.0 4 votes vote down vote up
@Override
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(Key key,
		QueryMethodEvaluationContextProvider evaluationContextProvider) {

	return Optional.of(new Neo4jQueryLookupStrategy(neo4jOperations, mappingContext, evaluationContextProvider));
}
 
Example #10
Source File: SolrRepositoryFactory.java    From dubbox with Apache License 2.0 4 votes vote down vote up
@Override
protected QueryLookupStrategy getQueryLookupStrategy(Key key) {
	return new SolrQueryLookupStrategy();
}
 
Example #11
Source File: AclJpaRepositoryFactoryBean.java    From strategy-spring-security-acl with Apache License 2.0 4 votes vote down vote up
@Override
protected QueryLookupStrategy getQueryLookupStrategy(Key key,
    EvaluationContextProvider evaluationContextProvider) {
  return new AclQueryLookupStrategy(key, evaluationContextProvider);
}
 
Example #12
Source File: AclJpaRepositoryFactoryBean.java    From strategy-spring-security-acl with Apache License 2.0 4 votes vote down vote up
public AclQueryLookupStrategy(Key key, EvaluationContextProvider evaluationContextProvider) {
  this.key = key;
  this.evaluationContextProvider = evaluationContextProvider;
}
 
Example #13
Source File: KeyValueRepositoryFactory.java    From spring-data-keyvalue with Apache License 2.0 4 votes vote down vote up
@Override
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(@Nullable Key key,
		QueryMethodEvaluationContextProvider evaluationContextProvider) {
	return Optional.of(new KeyValueQueryLookupStrategy(key, evaluationContextProvider, this.keyValueOperations,
			this.queryCreator, this.repositoryQueryType));
}
 
Example #14
Source File: DynamoDBRepositoryFactory.java    From spring-data-dynamodb with Apache License 2.0 4 votes vote down vote up
@Override
protected QueryLookupStrategy getQueryLookupStrategy(Key key) {
	return DynamoDBQueryLookupStrategy.create(dynamoDBOperations, key);
}