use of org.springframework.data.relational.core.query.Query in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithNullMatchingLastName.
// GH-929
@Test
void queryByExampleWithNullMatchingLastName() {
Person person = new Person();
person.setLastname("Baggins");
ExampleMatcher matcher = matching().withIncludeNullValues();
Example<Person> example = Example.of(person, matcher);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria()).map(//
Object::toString).hasValue("(lastname IS NULL OR lastname = 'Baggins')");
}
use of org.springframework.data.relational.core.query.Query in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameOrLastname.
// GH-929
@Test
void queryByExampleWithFirstnameOrLastname() {
Person person = new Person();
person.setFirstname("Frodo");
person.setLastname("Baggins");
ExampleMatcher matcher = matchingAny();
Example<Person> example = Example.of(person, matcher);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria().map(Object::toString).get()).contains(//
"(firstname = 'Frodo')", //
" OR ", "(lastname = 'Baggins')");
}
Aggregations