本文整理了Java中org.springframework.data.domain.Example.of()
方法的一些代码示例,展示了Example.of()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Example.of()
方法的具体详情如下:
包路径:org.springframework.data.domain.Example
类名称:Example
方法名:of
[英]Create a new Example including all non-null properties by default.
[中]创建一个默认包含所有非空属性的新示例。
Official Spring framework guide
代码示例来源:origin: spring-guides/gs-accessing-data-mongodb
@Test
public void findsByExample() {
Customer probe = new Customer(null, "Matthews");
List<Customer> result = repository.findAll(Example.of(probe));
assertThat(result).hasSize(2).extracting("firstName").contains("Dave", "Oliver August");
}
}
代码示例来源:origin: spring-projects/spring-data-mongodb
/**
* Static factory method to create a {@link Criteria} matching an example object.
*
* @param example must not be {@literal null}.
* @return
* @see Criteria#alike(Example)
* @since 1.8
*/
public static Criteria byExample(Object example) {
return byExample(Example.of(example));
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
/**
* Static factory method to create a {@link Criteria} matching an example object.
*
* @param example must not be {@literal null}.
* @return
* @see Criteria#alike(Example)
* @since 1.8
*/
public static Criteria byExample(Object example) {
return byExample(Example.of(example));
}
代码示例来源:origin: wyh-spring-ecosystem-student/spring-boot-student
@Override
@Cacheable(value = "people1", key = "#person.id", depict = "用户信息缓存1",
firstCache = @FirstCache(expireTime = 4),
secondaryCache = @SecondaryCache(expireTime = 15, preloadTime = 8, forceRefresh = true))
public Person findOne1(Person person) {
Person p = personRepository.findOne(Example.of(person));
logger.info("为id、key为:" + p.getId() + "数据做了缓存");
return p;
}
}
代码示例来源:origin: wyh-spring-ecosystem-student/spring-boot-student
@Override
@Cacheable(value = "'people' + ':' + #person.id", key = "#person.id", depict = "用户信息缓存",
firstCache = @FirstCache(expireTime = 4),
secondaryCache = @SecondaryCache(expireTime = 15, preloadTime = 8, forceRefresh = true))
public Person findOne(Person person) {
Person p = personRepository.findOne(Example.of(person));
logger.info("为id、key为:" + p.getId() + "数据做了缓存");
return p;
}
代码示例来源:origin: getheimdall/heimdall
/**
* Generates a list of {@link Interceptor} from a request.
*
* @param interceptorDTO The {@link InterceptorDTO}
* @return The List<{@link Interceptor}> list
*/
@Transactional(readOnly = true)
public List<Interceptor> list(InterceptorDTO interceptorDTO) {
Interceptor interceptor = GenericConverter.mapper(interceptorDTO, Interceptor.class);
Example<Interceptor> example = Example.of(interceptor, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING));
return interceptorRepository.findAll(example);
}
代码示例来源:origin: getheimdall/heimdall
/**
* Creates a list of {@link Role} from a request.
*
* @param roleDTO {@link RoleDTO}
* @return {@link List} of {@link Role}
*/
@Transactional(readOnly = false)
public List<Role> list(RoleDTO roleDTO) {
Role role = GenericConverter.mapper(roleDTO, Role.class);
Example<Role> example = Example.of(role, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING));
List<Role> roles = roleRepository.findAll(example);
return roles;
}
代码示例来源:origin: getheimdall/heimdall
/**
* Creates a list of {@link User} from a request.
*
* @param userDTO {@link UserDTO}
* @return {@link List} of {@link User}
*/
@Transactional(readOnly = false)
public List<User> list(UserDTO userDTO) {
User user = GenericConverter.mapper(userDTO, User.class);
Example<User> example = Example.of(user, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING));
List<User> users = userRepository.findAll(example);
return users;
}
代码示例来源:origin: getheimdall/heimdall
/**
* Generates a list of {@link App}.
*
* @param appDTO The {@link AppDTO}
* @return The list of {@link App}'s
*/
@Transactional(readOnly = true)
public List<App> list(AppRequestDTO appDTO) {
App app = GenericConverter.mapper(appDTO, App.class);
Example<App> example = Example.of(app, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING));
List<App> apps = appRepository.findAll(example);
return apps;
}
代码示例来源:origin: getheimdall/heimdall
/**
* Generates a list of the {@link Api}'s
*
* @param apiDTO {@link ApiDTO}
* @return The list of {@link Api}'s
*/
public List<Api> list(ApiDTO apiDTO) {
Api api = GenericConverter.mapper(apiDTO, Api.class);
Example<Api> example = Example.of(api, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING));
List<Api> apis = apiRepository.findAll(example);
return apis;
}
代码示例来源:origin: getheimdall/heimdall
/**
* Generates a list of {@link Environment} from a request.
*
* @param environmentDTO The {@link EnvironmentDTO}
* @return The List<{@link Environment}>
*/
public List<Environment> list(EnvironmentDTO environmentDTO) {
Environment environment = GenericConverter.mapper(environmentDTO, Environment.class);
Example<Environment> example = Example.of(environment, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING));
return environmentRepository.findAll(example);
}
代码示例来源:origin: getheimdall/heimdall
/**
* Finds a {@link List} of {@link Privilege} associated with one Privilege provided.
*
* @param privilegeDTO {@link PrivilegeDTO}
* @return {@link List} of {@link Privilege}
*/
public List<Privilege> list(PrivilegeDTO privilegeDTO) {
Privilege privilege = GenericConverter.mapper(privilegeDTO, Privilege.class);
Example<Privilege> example = Example.of(privilege, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING));
List<Privilege> privileges = repository.findAll(example);
return privileges;
}
代码示例来源:origin: weechang/moreco
@Override
public PageModel<Dept> findAll(Dept param, Pageable pageable) {
ExampleMatcher matcher = ExampleMatcher.matching()
.withMatcher("name" ,ExampleMatcher.GenericPropertyMatchers.contains());
return new PageModel<>(baseDao.findAll(Example.of(param, matcher), pageable));
}
代码示例来源:origin: weechang/moreco
@Override
public PageModel<Menu> findAll(Menu param, Pageable pageable) {
ExampleMatcher matcher = ExampleMatcher.matching()
.withMatcher("name" ,ExampleMatcher.GenericPropertyMatchers.contains());
PageModel<Menu> page = new PageModel<>(baseDao.findAll(Example.of(param, matcher), pageable));
return page;
}
代码示例来源:origin: getheimdall/heimdall
/**
* Generates a list of {@link Developer} from a request.
*
* @param developerDTO The {@link DeveloperDTO}
* @return The list of {@link Developer}
*/
public List<Developer> list(DeveloperDTO developerDTO) {
Developer developer = GenericConverter.mapper(developerDTO, Developer.class);
Example<Developer> example = Example.of(developer, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING));
List<Developer> developers = developerRepository.findAll(example);
return developers;
}
代码示例来源:origin: weechang/moreco
@Override
public PageModel<Role> findAll(Role param, Pageable pageable) {
ExampleMatcher matcher = ExampleMatcher.matching()
.withMatcher("name" ,ExampleMatcher.GenericPropertyMatchers.contains());
return new PageModel<>( baseDao.findAll(Example.of(param, matcher), pageable));
}
代码示例来源:origin: getheimdall/heimdall
/**
* Generates a list of {@link Provider} from a request
*
* @param providerDTO The {@link ProviderDTO}
* @return The list of {@link Provider}
*/
public List<Provider> listWithFilter(ProviderDTO providerDTO) {
Provider provider = GenericConverter.mapper(providerDTO, Provider.class);
Example<Provider> example = Example.of(provider,
ExampleMatcher.matching().withIgnorePaths("providerDefault").withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING));
return this.providerRepository.findAll(example);
}
代码示例来源:origin: mmnaseri/spring-data-mock
public List<Customer> findCustomersByName(String firstName, String lastName) {
final Customer probe = new Customer();
probe.setFirstName(firstName);
probe.setLastName(lastName);
final ExampleMatcher matcher = ExampleMatcher.matching()
.withMatcher("firstName", ignoreCase())
.withMatcher("lastName", ignoreCase());
final Example<Customer> example = Example.of(probe, matcher);
return repository.findByExample(example);
}
代码示例来源:origin: weechang/moreco
@Override
public PageModel<Resource> findAll(Resource param, Pageable pageable) {
ExampleMatcher matcher = ExampleMatcher.matching()
.withMatcher("name", ExampleMatcher.GenericPropertyMatchers.contains())
.withMatcher("tag", ExampleMatcher.GenericPropertyMatchers.contains())
.withMatcher("path", ExampleMatcher.GenericPropertyMatchers.contains());
return new PageModel<>(baseDao.findAll(Example.of(param, matcher), pageable));
}
代码示例来源:origin: weechang/moreco
@Override
public PageModel<User> findAll(User param, Pageable pageable) {
ExampleMatcher matcher = ExampleMatcher.matching()
.withMatcher("username", ExampleMatcher.GenericPropertyMatchers.contains())
.withMatcher("realName", ExampleMatcher.GenericPropertyMatchers.contains())
.withMatcher("email", ExampleMatcher.GenericPropertyMatchers.contains())
.withMatcher("mobile", ExampleMatcher.GenericPropertyMatchers.contains());
return new PageModel<>(baseDao.findAll(Example.of(param, matcher), pageable));
}
内容来源于网络,如有侵权,请联系作者删除!