use of org.springframework.data.relational.core.query.Query in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleEvenHandlesInvisibleFields.
// GH-929
@Test
void queryByExampleEvenHandlesInvisibleFields() {
Person person = new Person();
person.setFirstname("Frodo");
person.setSecret("I have the ring!");
Example<Person> example = Example.of(person);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria().map(Object::toString).get()).contains(//
"(firstname = 'Frodo')", //
" AND ", "(secret = 'I have the ring!')");
}
use of org.springframework.data.relational.core.query.Query in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstname.
// GH-929
@Test
void queryByExampleWithFirstname() {
Person person = new Person();
person.setFirstname("Frodo");
Example<Person> example = Example.of(person);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria()).map(//
Object::toString).hasValue("(firstname = 'Frodo')");
}
use of org.springframework.data.relational.core.query.Query in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameWithStringMatchingAtTheBeginning.
// GH-929
@Test
void queryByExampleWithFirstnameWithStringMatchingAtTheBeginning() {
Person person = new Person();
person.setFirstname("Fro");
ExampleMatcher matcher = matching().withStringMatcher(STARTING);
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 queryByExampleWithFirstnameWithFieldSpecificStringMatcherEndsWith.
// GH-929
@Test
void queryByExampleWithFirstnameWithFieldSpecificStringMatcherEndsWith() {
Person person = new Person();
person.setFirstname("do");
ExampleMatcher matcher = matching().withMatcher("firstname", endsWith());
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 queryByExampleWithFirstnameIgnoreCase.
// GH-929
@Test
void queryByExampleWithFirstnameIgnoreCase() {
Person person = new Person();
person.setFirstname("Frodo");
ExampleMatcher matcher = matching().withIgnoreCase(true);
Example<Person> example = Example.of(person, matcher);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria()).map(//
Object::toString).hasValue("(firstname = 'Frodo')");
assertThat(example.getMatcher().isIgnoreCaseEnabled()).isTrue();
}
Aggregations