Search in sources :

Example 6 with ProjectionFactory

use of org.springframework.data.projection.ProjectionFactory in project spring-data-mongodb by spring-projects.

the class StringBasedMongoQueryUnitTests method createQueryForMethod.

private StringBasedMongoQuery createQueryForMethod(String name, Class<?>... parameters) {
    try {
        Method method = SampleRepository.class.getMethod(name, parameters);
        ProjectionFactory factory = new SpelAwareProxyProjectionFactory();
        MongoQueryMethod queryMethod = new MongoQueryMethod(method, new DefaultRepositoryMetadata(SampleRepository.class), factory, converter.getMappingContext());
        return new StringBasedMongoQuery(queryMethod, operations, PARSER, DefaultEvaluationContextProvider.INSTANCE);
    } catch (Exception e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
Also used : ProjectionFactory(org.springframework.data.projection.ProjectionFactory) SpelAwareProxyProjectionFactory(org.springframework.data.projection.SpelAwareProxyProjectionFactory) SpelAwareProxyProjectionFactory(org.springframework.data.projection.SpelAwareProxyProjectionFactory) DefaultRepositoryMetadata(org.springframework.data.repository.core.support.DefaultRepositoryMetadata) Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)6 ProjectionFactory (org.springframework.data.projection.ProjectionFactory)6 SpelAwareProxyProjectionFactory (org.springframework.data.projection.SpelAwareProxyProjectionFactory)6 DefaultRepositoryMetadata (org.springframework.data.repository.core.support.DefaultRepositoryMetadata)6 JSONParseException (com.mongodb.util.JSONParseException)1 ExpectedException (org.junit.rules.ExpectedException)1