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>

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

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

Author:
Oliver Gierke

Nested Class Summary
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.
 
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, EntityPathResolver resolver)
          Creates a new QueryDslMongoRepository for the given MongoEntityInformation, MongoTemplate and 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.
 long count(Predicate predicate)
           
private   createQueryFor(Predicate predicate)
          Creates a MongodbQuery for the given Predicate.
 java.util.List<T> findAll(Predicate predicate)
           
 java.util.List<T> findAll(Predicate predicate, ... orders)
           
  findAll(Predicate predicate, Pageable pageable)
           
 T findOne(Predicate 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, 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 SimpleEntityPathResolver to create an EntityPath for the given domain class.

Parameters:
entityInformation -
template -

QueryDslMongoRepository

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

Parameters:
entityInformation -
template -
resolver -
Method Detail

findOne

public T findOne(Predicate predicate)
Overrides:
findOne in class SimpleMongoRepository<T,ID extends java.io.Serializable>

findAll

public java.util.List<T> findAll(Predicate predicate)
Overrides:
findAll in class SimpleMongoRepository<T,ID extends java.io.Serializable>

findAll

public java.util.List<T> findAll(Predicate predicate,
                                 ... orders)

findAll

public  findAll(Predicate predicate,
                     Pageable pageable)

count

public long count(Predicate predicate)

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: