use of org.springframework.data.relational.core.query.Query in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameWithFieldSpecificStringMatcherStartsWith.
// GH-929
@Test
void queryByExampleWithFirstnameWithFieldSpecificStringMatcherStartsWith() {
Person person = new Person();
person.setFirstname("Fro");
ExampleMatcher matcher = matching().withMatcher("firstname", startsWith());
Example<Person> example = Example.of(person, matcher);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria()).map(//
Object::toString).hasValue("(firstname LIKE 'Fro%')");
}
use of org.springframework.data.relational.core.query.Query in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameIgnoreCaseFieldLevel.
// GH-929
@Test
void queryByExampleWithFirstnameIgnoreCaseFieldLevel() {
Person person = new Person();
person.setFirstname("fro");
ExampleMatcher matcher = matching().withMatcher("firstname", startsWith().ignoreCase());
Example<Person> example = Example.of(person, matcher);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria()).map(//
Object::toString).hasValue("(firstname LIKE 'fro%')");
assertThat(example.getMatcher().getPropertySpecifiers().getForPath("firstname").getIgnoreCase()).isTrue();
}
use of org.springframework.data.relational.core.query.Query in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameAndLastname.
// GH-929
@Test
void queryByExampleWithFirstnameAndLastname() {
Person person = new Person();
person.setFirstname("Frodo");
person.setLastname("Baggins");
Example<Person> example = Example.of(person);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria().map(Object::toString).get()).contains(//
"(firstname = 'Frodo')", //
" AND ", "(lastname = 'Baggins')");
}
use of org.springframework.data.relational.core.query.Query in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameAndLastnameWithNullMatchingIgnoringFirstName.
// GH-929
@Test
void queryByExampleWithFirstnameAndLastnameWithNullMatchingIgnoringFirstName() {
Person person = new Person();
person.setFirstname("Frodo");
person.setLastname("Baggins");
ExampleMatcher matcher = matching().withIncludeNullValues().withIgnorePaths("firstname");
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 queryByExampleWithId.
// GH-929
@Test
void queryByExampleWithId() {
Person person = new Person();
person.setId("id1");
Example<Person> example = Example.of(person);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria()).map(//
Objects::toString).hasValue("(id = 'id1')");
}
Aggregations