Uploaded image for project: 'Spring Data MongoDB'
  1. Spring Data MongoDB
  2. DATAMONGO-1870

Skip parameter not working in MongoTemplate#remove(Query, Class).

    XMLWordPrintable

    Details

      Description

      Next code will remove all entries without skipping first 10 entries:

      Criteria criteria = 
      	Criteria.where("key").is(key);
      Query query =
          Query
              .query(criteria)
              .with(new Sort(Sort.Direction.DESC, "date"))
              .skip(10);
      WriteResult writeResult =
          mongoTemplate.remove(query, Item.class);
      

      However MongoTemplate.findAllAndRemove works as expected:

      Criteria criteria = 
      	Criteria.where("key").is(key);
      Query query =
          Query
              .query(criteria)
              .with(new Sort(Sort.Direction.DESC, "date"))
              .skip(10);
      List<Item> writeResult =
          mongoTemplate.findAllAndRemove(query, Item.class);
      

      This code will leave first 10 entries, all other - deleted.

        Attachments

          Activity

            People

            Assignee:
            cstrobl Christoph Strobl
            Reporter:
            Hronom Eugene Tenkaev
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: