Code polishing.
This commit is contained in:
@@ -34,7 +34,11 @@ import com.mongodb.DBCursor;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
class MongoCursorUtils {
|
||||
abstract class MongoCursorUtils {
|
||||
|
||||
private MongoCursorUtils() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link CursorPreparer} applying the given {@link Pageable} to
|
||||
|
||||
@@ -95,13 +95,25 @@ public class MongoQuery implements RepositoryQuery {
|
||||
|
||||
protected List<?> readCollection(DBObject query) {
|
||||
|
||||
return operations.query(operations.getDefaultCollectionName(), query,
|
||||
method.getDomainClass());
|
||||
return operations.query(operations.getDefaultCollectionName(),
|
||||
query, method.getDomainClass());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Execution} for collection returning queries.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
class CollectionExecution extends Execution {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.data.document.mongodb.repository.MongoQuery.Execution
|
||||
* #execute(com.mongodb.DBObject)
|
||||
*/
|
||||
@Override
|
||||
public Object execute(DBObject query) {
|
||||
|
||||
@@ -173,11 +185,17 @@ public class MongoQuery implements RepositoryQuery {
|
||||
*/
|
||||
class SingleEntityExecution extends Execution {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.data.document.mongodb.repository.MongoQuery.Execution
|
||||
* #execute(com.mongodb.DBObject)
|
||||
*/
|
||||
@Override
|
||||
Object execute(DBObject query) {
|
||||
|
||||
List<?> result = readCollection(query);
|
||||
|
||||
return result.isEmpty() ? null : result.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,6 @@ class MongoQueryCreator extends AbstractQueryCreator<DBObject, QueryBuilder> {
|
||||
@Override
|
||||
protected DBObject finalize(QueryBuilder criteria, Sort sort) {
|
||||
|
||||
// TODO: apply sorting
|
||||
return criteria.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,10 +48,14 @@ public class SimpleMongoRepository<T, ID extends Serializable> extends
|
||||
|
||||
|
||||
/**
|
||||
* Creates a ew {@link SimpleMongoRepository} for the given domain class and
|
||||
* {@link MongoOperations}.
|
||||
*
|
||||
* @param domainClass
|
||||
* @param operations
|
||||
*/
|
||||
public SimpleMongoRepository(Class<T> domainClass, MongoOperations operations) {
|
||||
public SimpleMongoRepository(Class<T> domainClass,
|
||||
MongoOperations operations) {
|
||||
|
||||
super(domainClass);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user