use of org.springframework.data.domain.ExampleMatcher 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.domain.ExampleMatcher 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%')");
}
use of org.springframework.data.domain.ExampleMatcher in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameWithStringMatchingOnTheEndingIncludingNull.
// GH-929
@Test
void queryByExampleWithFirstnameWithStringMatchingOnTheEndingIncludingNull() {
Person person = new Person();
person.setFirstname("do");
ExampleMatcher matcher = matching().withStringMatcher(ENDING).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.domain.ExampleMatcher in project spring-data-commons by spring-projects.
the class ExampleSpecificationAccessorUnitTests method exactMatcherUsesExactMatching.
// DATACMNS-953
@Test
public void exactMatcherUsesExactMatching() {
ExampleMatcher matcher = //
ExampleMatcher.matching().withMatcher("firstname", exact());
assertThat(new ExampleMatcherAccessor(matcher).getPropertySpecifier("firstname").getStringMatcher()).isEqualTo(StringMatcher.EXACT);
}
use of org.springframework.data.domain.ExampleMatcher in project mecaworks by KadarH.
the class ClasseServiceImpl method classeList.
/**
* search with nom
*
* @param pageable page description
* @param search keyword
* @return Page
*/
@Override
public Page<Classe> classeList(Pageable pageable, String search) {
log.info("Service- ClasseServiceImpl Calling ClasseList with params :" + pageable + ", " + search);
try {
if (search.isEmpty()) {
log.debug("fetching Classe page");
return classeRepo.findAll(pageable);
} else {
log.debug("Searching by :" + search);
// creating example
Classe classe = new Classe();
classe.setNom(search);
// creating matcher
ExampleMatcher matcher = ExampleMatcher.matchingAny().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING).withIgnoreCase().withIgnoreNullValues();
Example<Classe> example = Example.of(classe, matcher);
log.debug("getting search results");
return classeRepo.findAll(example, pageable);
}
} catch (Exception e) {
log.debug("Failed retrieving list of Classes");
throw new OperationFailedException("Operation échouée", e);
}
}
Aggregations