use of org.springframework.data.relational.core.query.Query in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameWithStringMatchingAtTheBeginningIncludingNull.
// GH-929
@Test
void queryByExampleWithFirstnameWithStringMatchingAtTheBeginningIncludingNull() {
Person person = new Person();
person.setFirstname("Fro");
ExampleMatcher matcher = matching().withStringMatcher(STARTING).withIncludeNullValues();
Example<Person> example = Example.of(person, matcher);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria()).map(//
Object::toString).hasValue("(firstname IS NULL OR firstname LIKE 'Fro%')");
}
use of org.springframework.data.relational.core.query.Query in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameAndLastnameIgnoringFirstname.
// GH-929
@Test
void queryByExampleWithFirstnameAndLastnameIgnoringFirstname() {
Person person = new Person();
person.setFirstname("Frodo");
person.setLastname("Baggins");
ExampleMatcher matcher = matching().withIgnorePaths("firstname");
Example<Person> example = Example.of(person, matcher);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria()).map(//
Object::toString).hasValue("(lastname = 'Baggins')");
}
use of org.springframework.data.relational.core.query.Query in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameWithStringMatchingContaining.
// GH-929
@Test
void queryByExampleWithFirstnameWithStringMatchingContaining() {
Person person = new Person();
person.setFirstname("do");
ExampleMatcher matcher = matching().withStringMatcher(CONTAINING);
Example<Person> example = Example.of(person, matcher);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria()).map(//
Object::toString).hasValue("(firstname LIKE '%do%')");
}
use of org.springframework.data.relational.core.query.Query in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameWithStringMatchingContainingIncludingNull.
// GH-929
@Test
void queryByExampleWithFirstnameWithStringMatchingContainingIncludingNull() {
Person person = new Person();
person.setFirstname("do");
ExampleMatcher matcher = matching().withStringMatcher(CONTAINING).withIncludeNullValues();
Example<Person> example = Example.of(person, matcher);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria()).map(//
Object::toString).hasValue("(firstname IS NULL OR firstname LIKE '%do%')");
}
use of org.springframework.data.relational.core.query.Query in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameWithFieldSpecificStringMatcherContains.
// GH-929
@Test
void queryByExampleWithFirstnameWithFieldSpecificStringMatcherContains() {
Person person = new Person();
person.setFirstname("do");
ExampleMatcher matcher = matching().withMatcher("firstname", contains());
Example<Person> example = Example.of(person, matcher);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria()).map(//
Object::toString).hasValue("(firstname LIKE '%do%')");
}
Aggregations