org.springframework.data.projection.ProjectionFactory Java Examples

The following examples show how to use org.springframework.data.projection.ProjectionFactory. 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: ReactiveNeo4jQueryMethod.java    From sdn-rx with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new {@link ReactiveNeo4jQueryMethod} from the given parameters.
 *
 * @param method   must not be {@literal null}.
 * @param metadata must not be {@literal null}.
 * @param factory  must not be {@literal null}.
 */
ReactiveNeo4jQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory) {
	super(method, metadata, factory);

	if (hasParameterOfType(method, Pageable.class)) {

		TypeInformation<?> returnType = ClassTypeInformation.fromReturnTypeOf(method);

		boolean multiWrapper = ReactiveWrappers.isMultiValueType(returnType.getType());
		boolean singleWrapperWithWrappedPageableResult = ReactiveWrappers.isSingleValueType(returnType.getType())
			&& (PAGE_TYPE.isAssignableFrom(returnType.getRequiredComponentType())
			|| SLICE_TYPE.isAssignableFrom(returnType.getRequiredComponentType()));

		if (singleWrapperWithWrappedPageableResult) {
			throw new InvalidDataAccessApiUsageException(
				String.format("'%s.%s' must not use sliced or paged execution. Please use Flux.buffer(size, skip).",
					ClassUtils.getShortName(method.getDeclaringClass()), method.getName()));
		}

		if (!multiWrapper) {
			throw new IllegalStateException(String.format(
				"Method has to use a multi-item reactive wrapper return type. Offending method: %s",
				method.toString()));
		}
	}
}
 
Example #2
Source File: KeyValueRepositoryFactory.java    From spring-data-keyvalue with Apache License 2.0 6 votes vote down vote up
@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,
					QueryMethodEvaluationContextProvider.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);
}
 
Example #3
Source File: MybatisQueryMethod.java    From spring-data-mybatis with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new {@link QueryMethod} from the given parameters. Looks up the correct
 * query to use for following invocations of the method given.
 * @param method must not be {@literal null}.
 * @param metadata must not be {@literal null}.
 * @param factory must not be {@literal null}.
 */
public MybatisQueryMethod(Method method, RepositoryMetadata metadata,
		ProjectionFactory factory) {

	super(method, metadata, factory);

	Assert.notNull(method, "Method must not be null!");

	this.method = method;

	Assert.isTrue(!(isModifyingQuery() && getParameters().hasSpecialParameter()),
			String.format("Modifying method must not contain %s!", Parameters.TYPES));

	this.metadata = metadata;
	String namespace = getAnnotationValue("namespace", String.class);
	String statementName = getAnnotationValue("statement", String.class);
	this.namespace = StringUtils.hasText(namespace) ? namespace
			: metadata.getRepositoryInterface().getName();
	this.statementName = StringUtils.hasText(statementName) ? statementName
			: (method.getName() + UUID.randomUUID().toString().replace("-", ""));

}
 
Example #4
Source File: SpannerQueryLookupStrategy.java    From spring-cloud-gcp with Apache License 2.0 6 votes vote down vote up
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata,
		ProjectionFactory factory, NamedQueries namedQueries) {
	SpannerQueryMethod queryMethod = createQueryMethod(method, metadata, factory);
	Class<?> entityType = getEntityType(queryMethod);
	boolean isDml = queryMethod.getQueryAnnotation() != null && queryMethod.getQueryAnnotation().dmlStatement();

	if (queryMethod.hasAnnotatedQuery()) {
		Query query = queryMethod.getQueryAnnotation();
		return createSqlSpannerQuery(entityType, queryMethod, query.value(), isDml);
	}
	else if (namedQueries.hasQuery(queryMethod.getNamedQueryName())) {
		String sql = namedQueries.getQuery(queryMethod.getNamedQueryName());
		return createSqlSpannerQuery(entityType, queryMethod, sql, isDml);
	}

	return createPartTreeSpannerQuery(entityType, queryMethod);
}
 
Example #5
Source File: PartTreeDatastoreQueryTests.java    From spring-cloud-gcp with Apache License 2.0 6 votes vote down vote up
private PartTreeDatastoreQuery<Trade> createQuery(boolean isPageQuery, boolean isSliceQuery,
		ProjectionInformation projectionInformation) {
	ProjectionFactory projectionFactory = mock(ProjectionFactory.class);
	doReturn(projectionInformation != null ? projectionInformation : getProjectionInformationMock()).when(projectionFactory).getProjectionInformation(any());

	PartTreeDatastoreQuery<Trade> tradePartTreeDatastoreQuery = new PartTreeDatastoreQuery<>(this.queryMethod,
			this.datastoreTemplate,
			this.datastoreMappingContext, Trade.class, projectionFactory);
	PartTreeDatastoreQuery<Trade> spy = spy(tradePartTreeDatastoreQuery);
	doReturn(isPageQuery).when(spy).isPageQuery();
	doReturn(isSliceQuery).when(spy).isSliceQuery();
	doAnswer((invocation) -> invocation.getArguments()[0]).when(spy).processRawObjectForProjection(any());
	doAnswer((invocation) -> invocation.getArguments()[0]).when(spy).convertResultCollection(any(), isNotNull());

	return spy;
}
 
Example #6
Source File: ArangoRepositoryFactory.java    From spring-data with Apache License 2.0 6 votes vote down vote up
@Override
public RepositoryQuery resolveQuery(
	final Method method,
	final RepositoryMetadata metadata,
	final ProjectionFactory factory,
	final NamedQueries namedQueries) {

	final ArangoQueryMethod queryMethod = new ArangoQueryMethod(method, metadata, factory);
	final String namedQueryName = queryMethod.getNamedQueryName();

	if (namedQueries.hasQuery(namedQueryName)) {
		final String namedQuery = namedQueries.getQuery(namedQueryName);
		return new StringBasedArangoQuery(namedQuery, queryMethod, operations);
	} else if (queryMethod.hasAnnotatedQuery()) {
		return new StringBasedArangoQuery(queryMethod, operations);
	} else {
		return new DerivedArangoQuery(queryMethod, operations);
	}
}
 
Example #7
Source File: Neo4jQueryLookupStrategy.java    From sdn-rx with Apache License 2.0 6 votes vote down vote up
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory,
	NamedQueries namedQueries) {

	Neo4jQueryMethod queryMethod = new Neo4jQueryMethod(method, metadata, factory);
	String namedQueryName = queryMethod.getNamedQueryName();

	if (namedQueries.hasQuery(namedQueryName)) {
		return StringBasedNeo4jQuery.create(neo4jOperations, mappingContext, evaluationContextProvider, queryMethod,
			namedQueries.getQuery(namedQueryName));
	} else if (queryMethod.hasQueryAnnotation()) {
		return StringBasedNeo4jQuery.create(neo4jOperations, mappingContext, evaluationContextProvider, queryMethod);
	} else {
		return PartTreeNeo4jQuery.create(neo4jOperations, mappingContext, queryMethod);
	}
}
 
Example #8
Source File: ReactiveNeo4jQueryLookupStrategy.java    From sdn-rx with Apache License 2.0 6 votes vote down vote up
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory,
	NamedQueries namedQueries) {

	Neo4jQueryMethod queryMethod = new ReactiveNeo4jQueryMethod(method, metadata, factory);
	String namedQueryName = queryMethod.getNamedQueryName();

	if (namedQueries.hasQuery(namedQueryName)) {
		return ReactiveStringBasedNeo4jQuery
			.create(neo4jOperations, mappingContext, evaluationContextProvider, queryMethod,
			namedQueries.getQuery(namedQueryName));
	} else if (queryMethod.hasQueryAnnotation()) {
		return ReactiveStringBasedNeo4jQuery
			.create(neo4jOperations, mappingContext, evaluationContextProvider, queryMethod);
	} else {
		return ReactivePartTreeNeo4jQuery.create(neo4jOperations, mappingContext, queryMethod);
	}
}
 
Example #9
Source File: ReactiveCosmosRepositoryFactory.java    From spring-data-cosmosdb with MIT License 5 votes vote down vote up
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata,
                                    ProjectionFactory factory, NamedQueries namedQueries) {
    final ReactiveCosmosQueryMethod queryMethod = new ReactiveCosmosQueryMethod(method,
        metadata, factory);

    Assert.notNull(queryMethod, "queryMethod must not be null!");
    Assert.notNull(cosmosOperations, "dbOperations must not be null!");
    return new PartTreeReactiveCosmosQuery(queryMethod, cosmosOperations);

}
 
Example #10
Source File: AclJpaRepositoryFactoryBean.java    From strategy-spring-security-acl with Apache License 2.0 5 votes vote down vote up
/**
 * @since Spring data JPA 1.10.0
 */
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata,
      ProjectionFactory factory, NamedQueries namedQueries) {
  QueryLookupStrategy queryLookupStrategy =
      Factory.super.getQueryLookupStrategy(key, evaluationContextProvider);

  RepositoryQuery query = queryLookupStrategy.resolveQuery(method, metadata, factory, namedQueries);
  return wrapQuery(method, metadata, query);
}
 
Example #11
Source File: AggregateQueryProvider2Test.java    From mongodb-aggregate-query-support with Apache License 2.0 5 votes vote down vote up
@Test(dataProvider = "queryMethods", expectedExceptions = {JsonParseException.class})
public void testCreateAggregateQuery(String methodName) throws Exception {
  NonReactiveAggregateQuerySupportingRepositoryFactory factory =
      new NonReactiveAggregateQuerySupportingRepositoryFactory(mongoOperations, queryExecutor);
  Optional<QueryLookupStrategy> lookupStrategy = factory.getQueryLookupStrategy(CREATE_IF_NOT_FOUND, evaluationContextProvider);
  assertTrue(lookupStrategy.isPresent(), "Expecting non null lookupStrategy");
  Method method = TestAggregateRepository22.class.getMethod(methodName);
  RepositoryMetadata repositoryMetadata = new DefaultRepositoryMetadata(TestAggregateRepository22.class);
  ProjectionFactory projectionFactory = new SpelAwareProxyProjectionFactory();
  RepositoryQuery query = lookupStrategy.get().resolveQuery(method, repositoryMetadata, projectionFactory, null);
  assertNotNull(query);
  Object object = query.execute(new Object[0]);
  assertNull(object);
}
 
Example #12
Source File: ReactiveAggregateQueryProviderTest.java    From mongodb-aggregate-query-support with Apache License 2.0 5 votes vote down vote up
@Test(dataProvider = "queryMethods", expectedExceptions = {JsonParseException.class})
public void testCreateAggregateQuery(String methodName) throws Exception {
  ReactiveAggregateQuerySupportingRepositoryFactory factory = new ReactiveAggregateQuerySupportingRepositoryFactory(mongoOperations,
                                                                                                                    queryExecutor);
  Optional<QueryLookupStrategy> lookupStrategy = factory.getQueryLookupStrategy(CREATE_IF_NOT_FOUND, evaluationContextProvider);

  Assert.isTrue(lookupStrategy.isPresent(), "Lookup strategy must not be null");
  Method method = ReactiveTestAggregateRepository22.class.getMethod(methodName);
  RepositoryMetadata repositoryMetadata = new DefaultRepositoryMetadata(ReactiveTestAggregateRepository22.class);
  ProjectionFactory projectionFactory = new SpelAwareProxyProjectionFactory();
  RepositoryQuery query = lookupStrategy.get().resolveQuery(method, repositoryMetadata, projectionFactory, null);
  assertNotNull(query);
  Object object = query.execute(new Object[0]);
  assertNull(object);
}
 
Example #13
Source File: ReactiveAggregateQuerySupportingRepositoryFactory.java    From mongodb-aggregate-query-support with Apache License 2.0 5 votes vote down vote up
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata repositoryMetadata,
                                    ProjectionFactory projectionFactory, NamedQueries namedQueries) {
  if (!isAggregateQueryAnnotated(method)) {
    return parentQueryLookupStrategy.resolveQuery(method, repositoryMetadata, projectionFactory, namedQueries);
  }
  else {
    return new ReactiveAggregateMongoQuery(method, repositoryMetadata, mongoOperations, projectionFactory, queryExecutor);
  }
}
 
Example #14
Source File: NonReactiveAggregateQuerySupportingRepositoryFactory.java    From mongodb-aggregate-query-support with Apache License 2.0 5 votes vote down vote up
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata repositoryMetadata,
                                    ProjectionFactory projectionFactory, NamedQueries namedQueries) {
  if (!isAggregateQueryAnnotated(method)) {
    return parentQueryLookupStrategy.resolveQuery(method, repositoryMetadata, projectionFactory, namedQueries);
  }
  else {
    return new NonReactiveAggregateMongoQuery(method, repositoryMetadata, mongoOperations, projectionFactory, queryExecutor);
  }
}
 
Example #15
Source File: ReactiveAggregateMongoQuery.java    From mongodb-aggregate-query-support with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link AbstractMongoQuery} from the given {@link MongoQueryMethod} and {@link MongoOperations}.
 *
 * @param method must not be {@literal null}.
 * @param projectionFactory - the projection factory
 */
@Autowired
public ReactiveAggregateMongoQuery(Method method, RepositoryMetadata metadata, ReactiveMongoOperations mongoOperations,
                                   ProjectionFactory projectionFactory, MongoQueryExecutor queryExecutor) {
  super(new ReactiveMongoQueryMethod(method, metadata, projectionFactory,
                                     mongoOperations.getConverter().getMappingContext()),
        mongoOperations,
        new SpelExpressionParser(),
        CONTEXT_PROVIDER);
  this.mongoOperations = mongoOperations;
  this.method = method;
  this.queryExecutor = queryExecutor;
}
 
Example #16
Source File: NonReactiveAggregateMongoQuery.java    From mongodb-aggregate-query-support with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link AbstractMongoQuery} from the given {@link MongoQueryMethod} and {@link MongoOperations}.
 *
 * @param method must not be {@literal null}.
 * @param projectionFactory - the projection factory
 */
@Autowired
public NonReactiveAggregateMongoQuery(Method method, RepositoryMetadata metadata, MongoOperations mongoOperations,
                                      ProjectionFactory projectionFactory, MongoQueryExecutor queryExecutor) {
  super(new MongoQueryMethod(method, metadata, projectionFactory, mongoOperations.getConverter().getMappingContext()),
        mongoOperations,
        new SpelExpressionParser(),
        CONTEXT_PROVIDER);
  this.mongoOperations = mongoOperations;
  this.method = method;
  this.queryExecutor = queryExecutor;
}
 
Example #17
Source File: AggregateQueryProvider2Test.java    From mongodb-aggregate-query-support with Apache License 2.0 5 votes vote down vote up
@Test(dataProvider = "queryMethods", expectedExceptions = {JsonParseException.class})
public void testCreateAggregateQuery(String methodName) throws Exception {
  AggregateQuerySupportingRepositoryFactory factory = new AggregateQuerySupportingRepositoryFactory(mongoOperations,
                                                                                                    queryExecutor);
  QueryLookupStrategy lookupStrategy = factory.getQueryLookupStrategy(CREATE_IF_NOT_FOUND, evaluationContextProvider);

  Method method = TestAggregateRepository22.class.getMethod(methodName);
  RepositoryMetadata repositoryMetadata = new DefaultRepositoryMetadata(TestAggregateRepository22.class);
  ProjectionFactory projectionFactory = new SpelAwareProxyProjectionFactory();
  RepositoryQuery query = lookupStrategy.resolveQuery(method, repositoryMetadata, projectionFactory, null);
  assertNotNull(query);
  Object object = query.execute(new Object[0]);
  assertNull(object);
}
 
Example #18
Source File: AggregateQuerySupportingRepositoryFactory.java    From mongodb-aggregate-query-support with Apache License 2.0 5 votes vote down vote up
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata repositoryMetadata,
                                    ProjectionFactory projectionFactory, NamedQueries namedQueries) {
  if (!isAggregateQueryAnnotated(method)) {
    return parentQueryLookupStrategy.resolveQuery(method, repositoryMetadata, projectionFactory, namedQueries);
  }
  else {
    return new AggregateMongoQuery(method, repositoryMetadata, mongoOperations, projectionFactory, queryExecutor);
  }
}
 
Example #19
Source File: AggregateMongoQuery.java    From mongodb-aggregate-query-support with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link AbstractMongoQuery} from the given {@link MongoQueryMethod} and {@link MongoOperations}.
 *
 * @param method must not be {@literal null}.
 * @param projectionFactory - the projection factory
 */
@Autowired
public AggregateMongoQuery(Method method, RepositoryMetadata metadata, MongoOperations mongoOperations,
                           ProjectionFactory projectionFactory, MongoQueryExecutor queryExecutor) {
  super(new MongoQueryMethod(method, metadata, projectionFactory, mongoOperations.getConverter().getMappingContext()),
        mongoOperations);
  this.mongoOperations = mongoOperations;
  this.method = method;
  this.queryExecutor = queryExecutor;
}
 
Example #20
Source File: TemplateQueryLookupStrategy.java    From spring-data-jpa-extra with Apache License 2.0 5 votes vote down vote up
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory,
                                    NamedQueries namedQueries) {
    if (method.getAnnotation(TemplateQuery.class) == null) {
        return jpaQueryLookupStrategy.resolveQuery(method, metadata, factory, namedQueries);
    } else {
        return new FreemarkerTemplateQuery(new JpaQueryMethod(method, metadata, factory, extractor), entityManager);
    }
}
 
Example #21
Source File: EntityGraphAwareJpaQueryMethod.java    From spring-data-jpa-entity-graph with MIT License 5 votes vote down vote up
protected EntityGraphAwareJpaQueryMethod(
    Method method,
    RepositoryMetadata metadata,
    ProjectionFactory factory,
    QueryExtractor extractor) {
  super(method, metadata, factory, extractor);
}
 
Example #22
Source File: EbeanQueryMethod.java    From spring-data-ebean with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a {@link EbeanQueryMethod}.
 *
 * @param method   must not be {@literal null}
 * @param metadata must not be {@literal null}
 */
public EbeanQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory) {
    super(method, metadata, factory);

    Assert.notNull(method, "Method must not be null!");

    this.method = method;
}
 
Example #23
Source File: FirestoreQueryLookupStrategy.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata repositoryMetadata,
		ProjectionFactory projectionFactory, NamedQueries namedQueries) {
	// In this method we usually decide if the query method is a PartTree or an annotated
	// @Query method.
	// There is no choice in Firestore. We only have PartTree.
	return new PartTreeFirestoreQuery(
			new FirestoreQueryMethod(method, repositoryMetadata, projectionFactory),
			this.firestoreTemplate,
			this.firestoreTemplate.getMappingContext(),
			this.firestoreTemplate.getClassMapper()
	);
}
 
Example #24
Source File: IgniteRepositoryQuery.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param metadata Metadata.
 * @param qry Query.
 * @param mtd Method.
 * @param factory Factory.
 * @param cache Cache.
 */
public IgniteRepositoryQuery(RepositoryMetadata metadata, IgniteQuery qry,
    Method mtd, ProjectionFactory factory, IgniteCache cache) {
    type = metadata.getDomainType();
    this.qry = qry;
    this.cache = cache;
    this.metadata = metadata;
    this.mtd = mtd;
    this.factory = factory;

    returnStgy = calcReturnType(mtd, qry.isFieldQuery());
}
 
Example #25
Source File: SpannerQueryMethod.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link QueryMethod} from the given parameters. Looks up the correct
 * query to use for following invocations of the method given.
 *
 * @param method must not be {@literal null}.
 * @param metadata must not be {@literal null}.
 * @param factory must not be {@literal null}.
 * @param mappingContext the mapping context to use.
 */
public SpannerQueryMethod(Method method, RepositoryMetadata metadata,
		ProjectionFactory factory,
		MappingContext<? extends SpannerPersistentEntity<?>,
				SpannerPersistentProperty> mappingContext) {
	super(method, metadata, factory);

	Assert.notNull(mappingContext, "MappingContext must not be null!");

	this.method = method;
	this.mappingContext = mappingContext;
}
 
Example #26
Source File: IgniteRepositoryFactory.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@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())));
        }
    };
}
 
Example #27
Source File: PartTreeDatastoreQuery.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 * @param queryMethod the metadata for this query method.
 * @param datastoreTemplate used to execute the given query.
 * @param datastoreMappingContext used to provide metadata for mapping results to objects.
 * @param entityType the result domain type.
 * @param projectionFactory the projection factory that is used to get projection information.
 */
public PartTreeDatastoreQuery(DatastoreQueryMethod queryMethod,
							DatastoreOperations datastoreTemplate,
		DatastoreMappingContext datastoreMappingContext, Class<T> entityType, ProjectionFactory projectionFactory) {
	super(queryMethod, datastoreTemplate, datastoreMappingContext, entityType);
	this.tree = new PartTree(queryMethod.getName(), entityType);
	this.datastorePersistentEntity = this.datastoreMappingContext
			.getPersistentEntity(this.entityType);

	this.projectionFactory = projectionFactory;
	validateAndSetFilterParts();
}
 
Example #28
Source File: HazelcastQueryLookupStrategy.java    From spring-data-hazelcast with Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * Use {@link HazelcastPartTreeQuery} for resolving queries against Hazelcast repositories.
 * </P>
 *
 * @param Method,             the query method
 * @param RepositoryMetadata, not used
 * @param ProjectionFactory,  not used
 * @param NamedQueries,       not used
 * @return A mechanism for querying Hazelcast repositories
 */
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory projectionFactory,
                                    NamedQueries namedQueries) {

    HazelcastQueryMethod queryMethod = new HazelcastQueryMethod(method, metadata, projectionFactory);

    if (queryMethod.hasAnnotatedQuery()) {
        return new StringBasedHazelcastRepositoryQuery(queryMethod, hazelcastInstance);
    }

    return new HazelcastPartTreeQuery(queryMethod, evaluationContextProvider, this.keyValueOperations, this.queryCreator);
}
 
Example #29
Source File: CosmosRepositoryFactory.java    From spring-data-cosmosdb with MIT License 5 votes vote down vote up
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata,
                                    ProjectionFactory factory, NamedQueries namedQueries) {
    final CosmosQueryMethod queryMethod = new CosmosQueryMethod(method, metadata, factory);

    Assert.notNull(queryMethod, "queryMethod must not be null!");
    Assert.notNull(dbOperations, "dbOperations must not be null!");
    return new PartTreeCosmosQuery(queryMethod, dbOperations);

}
 
Example #30
Source File: HazelcastQueryMethod.java    From spring-data-hazelcast with Apache License 2.0 4 votes vote down vote up
public HazelcastQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory) {
    super(method, metadata, factory);
    this.method = method;
}