You forgot to add $
to operators. And I also suggest to use QueryBuilder for this case, it is much more convenient:
DBObject query = QueryBuilder.start("num1").lessThanEquals(7).and("num2").greaterThanEquals(7).get();
I assume that num1
is always not greater than num2
.