Announcement Announcement Module
Collapse
No announcement yet.
whick criterion use $ne operation? and i have problem when using in,nin Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • whick criterion use $ne operation? and i have problem when using in,nin

    i want to do $ne operation, but i have not found a criteria match it.
    and the in ,nin seems working incorrectly, i insert 4 persons
    Code:
    Person p1 = new Person("Bob", 33);
    mongoTemplate.insert(p1);
    Person p2 = new Person("Mary", 25);
    mongoTemplate.insert(p2);
    Person p3 = new Person("Chris", 68);
    mongoTemplate.insert(p3);
    Person p4 = new Person("Janet", 29);
    mongoTemplate.insert(p4);
    when i use in operation, it print none
    Code:
    List l = Arrays.asList(25);
    List<Person> ps = mongoTemplate.find(new Query(where("age").in(l)), Person.class);
    for(Person s : ps) {
        System.out.println(s);
    }
    and when i use nin operation, it print the all persons

    thank you for help!

  • #2
    oh, get it , in(),nin() need an array argument, where("age").in(l.toArray()) is working correctly

    Comment


    • #3
      Hi,

      I've created two issues to fix the usage issues you mention. DATADOC-106 is about adding some operations that aren't on the Criteria class, such as $ne. DATADOC-107 is to let you pass in collections instead of arrays so you don't have to do the l.toArray() yourself.

      Mark

      Comment

      Working...
      X