org.springframework.data.document.mongodb.repository
Class QueryDslMongoRepository<T,ID extends java.io.Serializable>

java.lang.Object
  extended by org.springframework.data.document.mongodb.repository.SimpleMongoRepository<T,ID>
      extended by org.springframework.data.document.mongodb.repository.QueryDslMongoRepository<T,ID>
All Implemented Interfaces:
QueryDslPredicateExecutor<T>

public class QueryDslMongoRepository<T,ID extends java.io.Serializable>
extends SimpleMongoRepository<T,ID>
implements QueryDslPredicateExecutor<T>

Special QueryDsl based repository implementation that allows execution Predicates in various forms. TODO: Extract QueryDslMongoRepository.EntityPathResolver into Spring Data Commons TODO: Refactor Spring Data JPA to use this common infrastructure

Author:
Oliver Gierke

Nested Class Summary
static interface QueryDslMongoRepository.EntityPathResolver
          Strategy interface to abstract the ways to translate an plain domain class into a EntityPath.
private  class QueryDslMongoRepository.MongoConverterTransformer
          QueryDslMongoRepository.MongoConverterTransformer implementation to delegate to a MongoConverter.
private  class QueryDslMongoRepository.MongoTemplateQuery
          Special MongodbQuery implementation to use our MongoOperations for actually accessing Mongo.
(package private) static class QueryDslMongoRepository.SimpleEntityPathResolver
          Simple implementation of QueryDslMongoRepository.EntityPathResolver to lookup a query class by reflection and using the static field of the same type.
 
Field Summary
private   builder
           
private  MongodbSerializer serializer
           
private  QueryDslMongoRepository.MongoConverterTransformer transformer
           
 
Constructor Summary
QueryDslMongoRepository(MongoEntityInformation<T,ID> entityInformation, MongoTemplate template)
          Creates a new QueryDslMongoRepository for the given EntityMetadata and MongoTemplate.
QueryDslMongoRepository(MongoEntityInformation<T,ID> entityInformation, MongoTemplate template, QueryDslMongoRepository.EntityPathResolver resolver)
          Creates a new QueryDslMongoRepository for the given MongoEntityInformation, MongoTemplate and QueryDslMongoRepository.EntityPathResolver.
 
Method Summary
private   applyPagination( query, Pageable pageable)
          Applies the given Pageable to the given MongodbQuery.
private   applySorting( query, Sort sort)
          Applies the given Sort to the given MongodbQuery.
 java.lang.Long count(Predicate predicate)
          Returns the number of instances that the given Predicate will return.
private   createQueryFor(Predicate predicate)
          Creates a MongodbQuery for the given Predicate.
 java.util.List<T> findAll(Predicate predicate)
          Returns all entities matching the given Predicate.
 java.util.List<T> findAll(Predicate predicate, ... orders)
          Returns all entities matching the given Predicate applying the given OrderSpecifiers.
  findAll(Predicate predicate, Pageable pageable)
          Returns all entities matching the given Predicate applying the given OrderSpecifiers.
 T findOne(Predicate predicate)
          Returns a single entity matching the given Predicate.
private   toOrder(Order order)
          Transforms a plain Order into a QueryDsl specific OrderSpecifier.
 
Methods inherited from class org.springframework.data.document.mongodb.repository.SimpleMongoRepository
count, delete, delete, deleteAll, exists, findAll, getEntityInformation, getMongoOperations, save, save
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transformer

private final QueryDslMongoRepository.MongoConverterTransformer transformer

serializer

private final MongodbSerializer serializer

builder

private final  builder
Constructor Detail

QueryDslMongoRepository

public QueryDslMongoRepository(MongoEntityInformation<T,ID> entityInformation,
                               MongoTemplate template)
Creates a new QueryDslMongoRepository for the given EntityMetadata and MongoTemplate. Uses the QueryDslMongoRepository.SimpleEntityPathResolver to create an EntityPath for the given domain class.

Parameters:
entityInformation -
template -

QueryDslMongoRepository

public QueryDslMongoRepository(MongoEntityInformation<T,ID> entityInformation,
                               MongoTemplate template,
                               QueryDslMongoRepository.EntityPathResolver resolver)
Creates a new QueryDslMongoRepository for the given MongoEntityInformation, MongoTemplate and QueryDslMongoRepository.EntityPathResolver.

Parameters:
entityInformation -
template -
resolver -
Method Detail

findOne

public T findOne(Predicate predicate)
Description copied from interface: QueryDslPredicateExecutor
Returns a single entity matching the given Predicate.

Specified by:
findOne in interface QueryDslPredicateExecutor<T>
Overrides:
findOne in class SimpleMongoRepository<T,ID extends java.io.Serializable>
Returns:

findAll

public java.util.List<T> findAll(Predicate predicate)
Description copied from interface: QueryDslPredicateExecutor
Returns all entities matching the given Predicate.

Specified by:
findAll in interface QueryDslPredicateExecutor<T>
Overrides:
findAll in class SimpleMongoRepository<T,ID extends java.io.Serializable>
Returns:

findAll

public java.util.List<T> findAll(Predicate predicate,
                                 ... orders)
Description copied from interface: QueryDslPredicateExecutor
Returns all entities matching the given Predicate applying the given OrderSpecifiers.

Specified by:
findAll in interface QueryDslPredicateExecutor<T>
Returns:

findAll

public  findAll(Predicate predicate,
                     Pageable pageable)
Description copied from interface: QueryDslPredicateExecutor
Returns all entities matching the given Predicate applying the given OrderSpecifiers.

Specified by:
findAll in interface QueryDslPredicateExecutor<T>
Returns:

count

public java.lang.Long count(Predicate predicate)
Description copied from interface: QueryDslPredicateExecutor
Returns the number of instances that the given Predicate will return.

Specified by:
count in interface QueryDslPredicateExecutor<T>
Parameters:
predicate - the Predicate to count instances for
Returns:
the number of instances

createQueryFor

private  createQueryFor(Predicate predicate)
Creates a MongodbQuery for the given Predicate.

Parameters:
predicate -
Returns:

applyPagination

private  applyPagination( query,
                              Pageable pageable)
Applies the given Pageable to the given MongodbQuery.

Parameters:
query -
pageable -
Returns:

applySorting

private  applySorting( query,
                           Sort sort)
Applies the given Sort to the given MongodbQuery.

Parameters:
query -
sort -
Returns:

toOrder

private  toOrder(Order order)
Transforms a plain Order into a QueryDsl specific OrderSpecifier.

Parameters:
order -
Returns: