org.springframework.data.simpledb.query.SimpleDbQueryLookupStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-data-simpledb Show documentation
Show all versions of spring-data-simpledb Show documentation
Provides a POJO centric model as per Spring Data interfaces to interact with Amazon SimpleDB, a non-relational datastore
package org.springframework.data.simpledb.query;
import org.springframework.data.repository.core.NamedQueries;
import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.data.repository.query.QueryLookupStrategy;
import org.springframework.data.repository.query.RepositoryQuery;
import org.springframework.data.simpledb.annotation.Query;
import org.springframework.data.simpledb.core.SimpleDbOperations;
import java.lang.reflect.Method;
/**
* Query lookup strategy to execute custom interface query methods
* Multiple query lookup strategies can be created and combined here:
*
* - create query from method name
* - from custom query annotations
*
*
* {@link QueryLookupStrategy} that tries to detect a declared query declared via simple db custom {@link Query}
* annotation.
*/
public final class SimpleDbQueryLookupStrategy implements QueryLookupStrategy {
private SimpleDbOperations simpleDbOperations;
public SimpleDbQueryLookupStrategy(SimpleDbOperations simpleDbOperations) {
this.simpleDbOperations = simpleDbOperations;
}
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, NamedQueries namedQueries) {
SimpleDbQueryMethod queryMethod;
if(SimpleDbQueryMethod.isAnnotatedQuery(method)) {
queryMethod = new SimpleDbQueryMethod(method, metadata, simpleDbOperations.getSimpleDb()
.getSimpleDbDomain());
} else {
queryMethod = new SimpleDbPartTreeQueryMethod(method, metadata, simpleDbOperations.getSimpleDb()
.getSimpleDbDomain());
}
return SimpleDbRepositoryQuery.fromQueryAnnotation(queryMethod, simpleDbOperations);
}
public static QueryLookupStrategy create(SimpleDbOperations simpleDbOperations, QueryLookupStrategy.Key key) {
// TODO check in Spring data core key switching and their semantics (look in spring-data-jpa)
return new SimpleDbQueryLookupStrategy(simpleDbOperations);
}
}