Package org.springframework.data.mongodb.core.query

Examples of org.springframework.data.mongodb.core.query.Criteria


    PartTree tree = new PartTree("findByFirstNameOrAge", Person.class);
    MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, "Dave", 42), context);

    Query query = creator.createQuery();
    assertThat(query, is(query(new Criteria().orOperator(where("firstName").is("Dave"), where("age").is(42)))));
  }
View Full Code Here


    PartTree tree = new PartTree("findByFirstNameOrAge", Person.class);
    MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, "Dave", 42), context);

    Query query = creator.createQuery();
    assertThat(query, is(query(new Criteria().orOperator(where("firstName").is("Dave"), where("age").is(42)))));
  }
View Full Code Here

      return null;
    }

    PersistentPropertyPath<MongoPersistentProperty> path = context.getPersistentPropertyPath(part.getProperty());
    MongoPersistentProperty property = path.getLeafProperty();
    Criteria criteria = from(part, property, where(path.toDotPath()), (PotentiallyConvertingIterator) iterator);

    return criteria;
  }
View Full Code Here

   * @see org.springframework.data.repository.query.parser.AbstractQueryCreator#or(java.lang.Object, java.lang.Object)
   */
  @Override
  protected Criteria or(Criteria base, Criteria criteria) {

    Criteria result = new Criteria();
    return result.orOperator(base, criteria);
  }
View Full Code Here

      return null;
    }

    PersistentPropertyPath<MongoPersistentProperty> path = context.getPersistentPropertyPath(part.getProperty());
    MongoPersistentProperty property = path.getLeafProperty();
    Criteria criteria = from(part, property, where(path.toDotPath()), (PotentiallyConvertingIterator) iterator);

    return criteria;
  }
View Full Code Here

   * @see org.springframework.data.repository.query.parser.AbstractQueryCreator#or(java.lang.Object, java.lang.Object)
   */
  @Override
  protected Criteria or(Criteria base, Criteria criteria) {

    Criteria result = new Criteria();
    return result.orOperator(base, criteria);
  }
View Full Code Here

    } catch (InvalidMongoDbApiUsageException e) {}
  }

  @Test
  public void testOrQuery() {
    Query q = new Query(new Criteria().orOperator(where("name").is("Sven").and("age").lt(50), where("age").lt(50),
        where("name").is("Thomas")));
    String expected = "{ \"$or\" : [ { \"name\" : \"Sven\" , \"age\" : { \"$lt\" : 50}} , { \"age\" : { \"$lt\" : 50}} , { \"name\" : \"Thomas\"}]}";
    Assert.assertEquals(expected, q.getQueryObject().toString());
  }
View Full Code Here

    Assert.assertEquals(expected, q.getQueryObject().toString());
  }

  @Test
  public void testAndQuery() {
    Query q = new Query(new Criteria().andOperator(where("name").is("Sven"), where("age").lt(50)));
    String expected = "{ \"$and\" : [ { \"name\" : \"Sven\"} , { \"age\" : { \"$lt\" : 50}}]}";
    Assert.assertEquals(expected, q.getQueryObject().toString());
  }
View Full Code Here

    Assert.assertEquals(expected, q.getQueryObject().toString());
  }

  @Test
  public void testNorQuery() {
    Query q = new Query(new Criteria().norOperator(where("name").is("Sven"), where("age").lt(50),
        where("name").is("Thomas")));
    String expected = "{ \"$nor\" : [ { \"name\" : \"Sven\"} , { \"age\" : { \"$lt\" : 50}} , { \"name\" : \"Thomas\"}]}";
    Assert.assertEquals(expected, q.getQueryObject().toString());
  }
View Full Code Here

  public void shouldAddFullTextParamCorrectlyToDerivedQuery() {

    org.springframework.data.mongodb.core.query.Query query = deriveQueryFromMethod("findPersonByFirstname",
        new Object[] { "text", TextCriteria.forDefaultLanguage().matching("search") });

    assertThat(query, isTextQuery().searchingFor("search").where(new Criteria("firstname").is("text")));
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.mongodb.core.query.Criteria

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.