use of org.springframework.data.mongodb.repository.QPerson in project spring-data-mongodb by spring-projects.
the class QuerydslRepositorySupportTests method shouldAllowAny.
// DATAMONGO-1063
@Test
public void shouldAllowAny() {
person.setSkills(Arrays.asList("vocalist", "songwriter", "guitarist"));
operations.save(person);
QPerson p = QPerson.person;
SpringDataMongodbQuery<Person> query = repoSupport.from(p).where(p.skills.any().in("guitarist"));
assertThat(query.fetchOne(), is(person));
}
use of org.springframework.data.mongodb.repository.QPerson in project spring-data-mongodb by spring-projects.
the class QuerydslMongoPredicateExecutorIntegrationTests method setup.
@Before
public void setup() {
MongoRepositoryFactory factory = new MongoRepositoryFactory(operations);
MongoEntityInformation<Person, String> entityInformation = factory.getEntityInformation(Person.class);
repository = new QuerydslMongoPredicateExecutor<Person>(entityInformation, operations);
operations.dropCollection(Person.class);
dave = new Person("Dave", "Matthews", 42);
oliver = new Person("Oliver August", "Matthews", 4);
carter = new Person("Carter", "Beauford", 49);
person = new QPerson("person");
operations.insertAll(Arrays.asList(oliver, dave, carter));
}
use of org.springframework.data.mongodb.repository.QPerson in project spring-data-mongodb by spring-projects.
the class QuerydslRepositorySupportTests method shouldAllowDbRefAgainstIdProperty.
// DATAMONGO-1394
@Test
public void shouldAllowDbRefAgainstIdProperty() {
User bart = new User();
bart.setUsername("bart@simpson.com");
operations.save(bart);
person.setCoworker(bart);
operations.save(person);
QPerson p = QPerson.person;
SpringDataMongodbQuery<Person> queryUsingIdField = repoSupport.from(p).where(p.coworker.id.eq(bart.getId()));
SpringDataMongodbQuery<Person> queryUsingRefObject = repoSupport.from(p).where(p.coworker.eq(bart));
assertThat(queryUsingIdField.fetchOne(), equalTo(person));
assertThat(queryUsingIdField.fetchOne(), equalTo(queryUsingRefObject.fetchOne()));
}
use of org.springframework.data.mongodb.repository.QPerson in project spring-data-mongodb by spring-projects.
the class QuerydslRepositorySupportTests method providesMongoQuery.
@Test
public void providesMongoQuery() {
QPerson p = QPerson.person;
QuerydslRepositorySupport support = new QuerydslRepositorySupport(operations) {
};
SpringDataMongodbQuery<Person> query = support.from(p).where(p.lastname.eq("Matthews"));
assertThat(query.fetchOne(), is(person));
}