Buggy code:
public class MongoContainer < Bean > extends AbstractContainer implements Container , Container . Filterable , Container . Indexed , Container . ItemSetChangeNotifier , Container . Ordered , Container . Sortable { public static class Builder < BT > { private static final int DEFAULT_PAGE_SIZE = 100 ; private final MongoOperations mongoOps ; private Criteria mongoCriteria = new Criteria ( ) ; private final Class < BT > beanClass ; private Sort sort ; private int pageSize = MongoContainer . Builder . DEFAULT_PAGE_SIZE ; private LinkedHashMap < String , Class < ? > > simpleProperties = new LinkedHashMap < String , Class < ? > > ( ) ; private LinkedHashMap < String , Class < ? > > nestedProperties = new LinkedHashMap < String , Class < ? > > ( ) ; private boolean hasCustomPropertyList = false ; private BeanFactory < BT > beanFactory ; private FilterConverter filterConverter = new DefaultFilterConverter ( ) ; public static < T > MongoContainer . Builder < T > forEntity ( final Class < T > beanClass , final MongoOperations mongoOps ) { } private Builder ( final Class < BT > beanClass , final MongoOperations mongoOps ) { } public MongoContainer . Builder < BT > withBeanFactory ( BeanFactory < BT > beanFactory ) { } public MongoContainer . Builder < BT > forCriteria ( final Criteria mongoCriteria ) { } public MongoContainer . Builder < BT > sortedBy ( final Sort sort ) { } public MongoContainer . Builder < BT > withPageSize ( final int pageSize ) { } public MongoContainer . Builder < BT > withProperty ( String id , Class < ? > type ) { } public MongoContainer . Builder < BT > withNestedProperty ( String id , Class < ? > type ) { } public MongoContainer . Builder < BT > withFilterConverter ( FilterConverter customFilterConverter ) { } public MongoContainer < BT > build ( ) { } public BufferedMongoContainer < BT > buildBuffered ( ) { } } protected static final String ID = "_id" ; protected static final Logger log = Logger . getLogger ( "MongoContainer" ) ; @ Nonnull protected Page < ObjectId > page ; protected final int pageSize ; protected final Criteria criteria ; protected Query query ; protected final Query baseQuery ; protected final Sort baseSort ; protected Sort sort ; protected final FilterConverter filterConverter ; protected final List < Filter > appliedFilters = new ArrayList < Filter > ( ) ; protected final List < Criteria > appliedCriteria = new ArrayList < Criteria > ( ) ; protected final MongoOperations mongoOps ; protected final Class < Bean > beanClass ; protected final BeanFactory < Bean > beanFactory ; protected final Map < String , Class < ? > > simpleProperties ; protected final Map < String , Class < ? > > nestedProperties ; protected final List < Object > allProperties ; MongoContainer ( MongoContainer . Builder < Bean > bldr ) { } protected DBCursor cursor ( ) { <START_BUG> Query q = makeBaseQuery ( ) ; <END_BUG> DBObject criteriaObject = q . getQueryObject ( ) ; DBObject projectionObject = new BasicDBObject ( MongoContainer . ID , true ) ; String collectionName = mongoOps . getCollectionName ( beanClass ) ; DBCollection dbCollection = mongoOps . getCollection ( collectionName ) ; DBCursor cursor = dbCollection . find ( criteriaObject , projectionObject ) ; if ( ( ( this . baseSort ) != null ) || ( ( this . sort ) != null ) ) { DBObject sortObject = q . getSortObject ( ) ; cursor . sort ( sortObject ) ; } return cursor ; } protected DBCursor cursorInRange ( int skip , int limit ) { } protected void fetchPage ( int offset , int pageSize ) { } protected Page < ObjectId > page ( ) { } public BeanItem < Bean > getItem ( Object o ) { } protected BeanItem < Bean > makeBeanItem ( Bean document ) { } @ Override public Collection < ? > getContainerPropertyIds ( ) { } @ Override @ Deprecated public List < ObjectId > getItemIds ( ) { } @ Override public Property < ? > getContainerProperty ( Object itemId , Object propertyId ) { } @ Override public Class < ? > getType ( Object propertyId ) { } @ Override public int size ( ) { } @ Override public boolean containsId ( Object itemId ) { } @ Override public BeanItem < Bean > addItem ( Object itemId ) throws UnsupportedOperationException { } @ Override public ObjectId addItem ( ) throws UnsupportedOperationException { } public ObjectId addEntity ( Bean target ) { } @ Override public boolean removeItem ( Object itemId ) throws UnsupportedOperationException { } @ Override public boolean addContainerProperty ( Object o , Class < ? > aClass , Object o2 ) throws UnsupportedOperationException { } @ Override public boolean removeContainerProperty ( Object o ) throws UnsupportedOperationException { } @ Override public boolean removeAllItems ( ) throws UnsupportedOperationException { } @ Override public int indexOfId ( Object itemId ) { } @ Override @ Nullable public ObjectId getIdByIndex ( int index ) { } @ Override public List < ObjectId > getItemIds ( int startIndex , int numberOfItems ) { } @ Override public Object addItemAt ( int index ) throws UnsupportedOperationException { } @ Override public Item addItemAt ( int index , Object newItemId ) throws UnsupportedOperationException { } @ Override public ObjectId nextItemId ( Object itemId ) { } @ Override public ObjectId prevItemId ( Object itemId ) { } @ Override public ObjectId firstItemId ( ) { } @ Override public ObjectId lastItemId ( ) { } @ Override public boolean isFirstId ( Object itemId ) { } @ Override public boolean isLastId ( Object itemId ) { } @ Override public Object addItemAfter ( Object previousItemId ) throws UnsupportedOperationException { } @ Override public Item addItemAfter ( Object previousItemId , Object newItemId ) throws UnsupportedOperationException { }

Fix:
final Query q = this . query ;