Java 类org.springframework.data.domain.Example 实例源码

项目:resilient-transport-service    文件:AddressService.java   
public Address validateAddress(AddressDTO addressDTO) {

        Address addressToSearch = new Address(addressDTO.getCountry(), addressDTO.getCity(), addressDTO.getPostcode(),
            addressDTO.getStreet(), addressDTO.getStreetNumber());

        //@formatter:off
        ExampleMatcher matcher =
            ExampleMatcher.matching()
                    .withMatcher("country", startsWith().ignoreCase())
                    .withMatcher("postcode", startsWith().ignoreCase())
                    .withMatcher("street", contains().ignoreCase())
                    .withMatcher("streetNumber", contains().ignoreCase())
                    .withMatcher("city", contains().ignoreCase());

        //@formatter:on
        Example<Address> searchExample = Example.of(addressToSearch, matcher);

        return addressRepository.findOne(searchExample);

    }
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final String email) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setEmail(email);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:QueryTests.java   
@Test
public void testSingle() {
    // tag::example-mono[]
    Employee e = new Employee();
    e.setFirstName("Bilbo");
    Example<Employee> example = Example.of(e);
    // end::example-mono[]

    // tag::query-mono[]
    Mono<Employee> singleEmployee = repository.findOne(example);
    // end::query-mono[]

    StepVerifier.create(singleEmployee)
        .expectNextMatches(employee -> {
            assertThat(employee).hasNoNullFieldsOrProperties();
            assertThat(employee.getFirstName()).isEqualTo("Bilbo");
            assertThat(employee.getLastName()).isEqualTo("Baggins");
            assertThat(employee.getRole()).isEqualTo("burglar");
            return true;
        })
        .expectComplete()
        .verify();
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:QueryTests.java   
@Test
public void testSingleWithTemplate() {
    // tag::mono-template[]
    Employee e = new Employee();
    e.setFirstName("Bilbo");
    Example<Employee> example = Example.of(e);

    Mono<Employee> singleEmployee = operations.findOne(
        new Query(byExample(example)), Employee.class);
    // end::mono-template[]

    StepVerifier.create(singleEmployee)
        .expectNextMatches(employee -> {
            assertThat(employee).hasNoNullFieldsOrProperties();
            assertThat(employee.getFirstName()).isEqualTo("Bilbo");
            assertThat(employee.getLastName()).isEqualTo("Baggins");
            assertThat(employee.getRole()).isEqualTo("burglar");
            return true;
        })
        .expectComplete()
        .verify();
}
项目:danyuan-application    文件:SysSeedServiceImpl.java   
/**
 * 方法名 : findAll
 * 功 能 : TODO(这里用一句话描述这个方法的作用)
 * 参 数 : @return
 * 参 考 : @see tk.ainiyue.admin.roles.service.SysRolesService#findAll()
 * 作 者 : Tenghui.Wang
 */

@Override
public Page<SysSeedInfo> findAll(int pageNumber, int pageSize, String searchText) {
    Sort sort = new Sort(new Order(Direction.DESC, "seedName"));
    PageRequest request = this.buildPageRequest(pageNumber, pageSize, sort);
    Page<SysSeedInfo> sourceCodes = null;
    if (searchText == null || "".equals(searchText)) {
        sourceCodes = sysSeedDao.findAll(request);
    } else {
        SysSeedInfo info = new SysSeedInfo();
        info.setSeedName(searchText);
        Example<SysSeedInfo> example = Example.of(info);
        sourceCodes = sysSeedDao.findAll(example, request);
    }
    return sourceCodes;
}
项目:danyuan-application    文件:SysSeedResultRulerServiceImpl.java   
@Override
public List<SysSeedResultRulerInfo> saveSysSeedResultRulerInfo(SysSeedResultRulerVo vo) {
    SysSeedResultRulerInfo info = new SysSeedResultRulerInfo();
    info.setTableUuid(vo.getTableUuid());
    info.setRulerUuid(vo.getRulerUuid());
    Example<SysSeedResultRulerInfo> example = Example.of(info);
    sysSeedResultRulerDao.delete(sysSeedResultRulerDao.findAll(example));
    if (vo.getList() != null) {
        for (SysSeedResultRulerInfo iterable_element : vo.getList()) {
            iterable_element.setTableUuid(vo.getTableUuid());
            iterable_element.setRulerUuid(vo.getRulerUuid());
            sysSeedResultRulerDao.save(iterable_element);
        }
    }
    return sysSeedResultRulerDao.findAll(example);
}
项目:spring-data-ebean    文件:ExampleExpressionBuilder.java   
/**
 * Return a ExampleExpression from Spring data Example
 *
 * @param ebeanServer
 * @param example
 * @param <T>
 * @return
 */
public static <T> ExampleExpression exampleExpression(EbeanServer ebeanServer, Example<T> example) {
  LikeType likeType;
  switch (example.getMatcher().getDefaultStringMatcher()) {
    case EXACT:
      likeType = LikeType.EQUAL_TO;
      break;
    case CONTAINING:
      likeType = LikeType.CONTAINS;
      break;
    case STARTING:
      likeType = LikeType.STARTS_WITH;
      break;
    case ENDING:
      likeType = LikeType.ENDS_WITH;
      break;
    default:
      likeType = LikeType.RAW;
      break;
  }
  return ebeanServer.getExpressionFactory().exampleLike(example.getProbe(),
      example.getMatcher().isIgnoreCaseEnabled(),
      likeType);
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:QueryTests.java   
@Test
public void testMultiple() {
    // tag::example-flux[]
    Employee e = new Employee();
    e.setLastName("baggins"); // Lowercase lastName

    ExampleMatcher matcher = ExampleMatcher.matching()
        .withIgnoreCase()
        .withMatcher("lastName", startsWith())
        .withIncludeNullValues();

    Example<Employee> example = Example.of(e, matcher);
    // end::example-flux[]

    // tag::query-flux[]
    Flux<Employee> multipleEmployees = repository.findAll(example);
    // end::query-flux[]

    StepVerifier.create(multipleEmployees.collectList())
        .expectNextMatches(employees -> {
            assertThat(employees).hasSize(2);
            assertThat(employees).extracting("firstName")
                .contains("Frodo", "Bilbo");
            return true;
        })
        .expectComplete()
        .verify();
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final int userId) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setId(userId);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:QueryTests.java   
@Test
public void testMultiple() {
    // tag::example-flux[]
    Employee e = new Employee();
    e.setLastName("baggins"); // Lowercase lastName

    ExampleMatcher matcher = ExampleMatcher.matching()
        .withIgnoreCase()
        .withMatcher("lastName", startsWith())
        .withIncludeNullValues();

    Example<Employee> example = Example.of(e, matcher);
    // end::example-flux[]

    // tag::query-flux[]
    Flux<Employee> multipleEmployees = repository.findAll(example);
    // end::query-flux[]

    StepVerifier.create(multipleEmployees.collectList())
        .expectNextMatches(employees -> {
            assertThat(employees).hasSize(2);
            assertThat(employees).extracting("firstName")
                .contains("Frodo", "Bilbo");
            return true;
        })
        .expectComplete()
        .verify();
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final int userId) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setId(userId);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final String email) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setEmail(email);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final String email) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setEmail(email);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final int userId) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setId(userId);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final int userId) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setId(userId);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final int userId) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setId(userId);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:danyuan-application    文件:SysUserBaseServiceImpl.java   
/**
 * 方法名 : findByName
 * 功 能 : TODO(这里用一句话描述这个方法的作用)
 * 参 数 : @param userName
 * 参 数 : @return
 * 参 考 : @see
 * tk.ainiyue.danyuan.application.user.userbase.service.SysUserBaseService#findByName(java.lang.String)
 * 作 者 : Administrator
 */

@Override
public SysUserBaseInfo findByName(String userName) {
    SysUserBaseInfo info = new SysUserBaseInfo();
    info.setUserName(userName);
    Example<SysUserBaseInfo> example = Example.of(info);
    SysUserBaseInfo sourceCodes = sysUserBaseDao.findOne(example);
    return sourceCodes;
}
项目:spring-data-ebean    文件:SimpleEbeanRepository.java   
@Override
public <S extends T> List<S> findAll(Example<S> example, Sort sort) {
    return db().find(example.getProbeType())
        .where(ExampleExpressionBuilder.exampleExpression(db(), example))
        .setOrder(Converters.convertToEbeanOrderBy(sort))
        .findList();
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final String email) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setEmail(email);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final String email) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setEmail(email);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final int userId) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setId(userId);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final int userId) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setId(userId);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final int userId) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setId(userId);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final String email) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setEmail(email);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:spring-data-examples    文件:UserRepositoryIntegrationTests.java   
/**
 * @see #153
 */
@Test
public void substringMatching() {

    Example<User> example = Example.of(new User("er", null, null), matching().//
            withStringMatcher(StringMatcher.ENDING));

    assertThat(repository.findAll(example), hasItems(skyler, walter));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final int userId) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setId(userId);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:spring-data-examples    文件:UserRepositoryIntegrationTests.java   
/**
 * @see #153
 */
@Test
public void configuringMatchersUsingLambdas() {

    Example<User> example = Example.of(new User("Walter", "WHITE", null),
            matching().//
                    withIgnorePaths("age").//
                    withMatcher("firstname", matcher -> matcher.startsWith()).//
                    withMatcher("lastname", matcher -> matcher.ignoreCase()));

    assertThat(repository.findAll(example), hasItems(flynn, walter));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final int userId) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setId(userId);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final int userId) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setId(userId);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:spring-data-examples    文件:UserRepositoryIntegrationTests.java   
/**
 * @see #153
 */
@Test
public void ignorePropertiesAndMatchByAge() {

    Example<Person> example = Example.of(flynn, matching(). //
            withIgnorePaths("firstname", "lastname"));

    assertThat(repository.findOne(example), is(flynn));
}
项目:spring-data-examples    文件:UserRepositoryIntegrationTests.java   
/**
 * @see #153
 */
@Test
public void substringMatching() {

    Example<Person> example = Example.of(new Person("er", null, null), matching().//
            withStringMatcher(StringMatcher.ENDING));

    assertThat(repository.findAll(example), hasItems(skyler, walter));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final int userId) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setId(userId);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:spring-data-examples    文件:UserRepositoryIntegrationTests.java   
/**
 * @see #153
 */
@Test
public void matchStartingStringsIgnoreCase() {

    Example<Person> example = Example.of(new Person("Walter", "WHITE", null),
            matching().//
                    withIgnorePaths("age").//
                    withMatcher("firstname", startsWith()).//
                    withMatcher("lastname", ignoreCase()));

    assertThat(repository.findAll(example), hasItems(flynn, walter));
}
项目:spring-data-examples    文件:UserRepositoryIntegrationTests.java   
/**
 * @see #153
 */
@Test
public void configuringMatchersUsingLambdas() {

    Example<Person> example = Example.of(new Person("Walter", "WHITE", null),
            matching().//
                    withIgnorePaths("age").//
                    withMatcher("firstname", matcher -> matcher.startsWith()).//
                    withMatcher("lastname", matcher -> matcher.ignoreCase()));

    assertThat(repository.findAll(example), hasItems(flynn, walter));
}
项目:spring-data-examples    文件:UserRepositoryIntegrationTests.java   
/**
 * @see #153
 */
@Test
public void valueTransformer() {

    Example<Person> example = Example.of(new Person(null, "White", 99), matching(). //
            withMatcher("age", matcher -> matcher.transform(value -> Integer.valueOf(50))));

    assertThat(repository.findAll(example), hasItems(walter));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final int userId) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setId(userId);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final String email) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setEmail(email);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final String email) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setEmail(email);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}
项目:spring-data-examples    文件:MongoOperationsIntegrationTests.java   
/**
 * @see #153
 */
@Test
public void configuringMatchersUsingLambdas() {

    Example<Person> example = Example.of(new Person("Walter", "WHITE", null),
            matching().//
                    withIgnorePaths("age"). //
                    withMatcher("firstname", matcher -> matcher.startsWith()). //
                    withMatcher("lastname", matcher -> matcher.ignoreCase()));

    assertThat(operations.find(query(byExample(example)), Person.class), hasItems(flynn, walter));
}
项目:Spring-Security-Third-Edition    文件:JpaEventDao.java   
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final int userId) {
    Event example = new Event();
    CalendarUser cu = new CalendarUser();
    cu.setId(userId);
    example.setOwner(cu);

    return repository.findAll(Example.of(example));
}