Package org.springframework.data.repository.core

Examples of org.springframework.data.repository.core.RepositoryInformation


   */
  public void registerCustomEditors(PropertyEditorRegistry registry) {

    for (Class<?> domainClass : repositories) {

      RepositoryInformation repositoryInformation = repositories.getRepositoryInformationFor(domainClass);
      RepositoryInvoker invoker = repositoryInvokerFactory.getInvokerFor(domainClass);

      DomainClassPropertyEditor<Object, Serializable> editor = new DomainClassPropertyEditor<Object, Serializable>(
          invoker, repositories.getEntityInformationFor(repositoryInformation.getDomainType()), registry);

      registry.registerCustomEditor(repositoryInformation.getDomainType(), editor);
    }
  }
View Full Code Here


      return source;
    }

    Class<?> domainType = targetType.getType();

    RepositoryInformation info = repositories.getRepositoryInformationFor(domainType);
    RepositoryInvoker invoker = repositoryInvokerFactory.getInvokerFor(domainType);

    return invoker.invokeFindOne(conversionService.convert(source, info.getIdType()));
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private RepositoryInvoker prepareInvokers(Class<?> domainType) {

    Object repository = repositories.getRepositoryFor(domainType);
    Assert.notNull(repository, String.format("No repository found for domain type: %s", domainType));
    RepositoryInformation information = repositories.getRepositoryInformationFor(domainType);

    if (repository instanceof PagingAndSortingRepository) {
      return new PagingAndSortingRepositoryInvoker((PagingAndSortingRepository<Object, Serializable>) repository,
          information, conversionService);
    } else if (repository instanceof CrudRepository) {
View Full Code Here

  @SuppressWarnings({ "unchecked" })
  public <T> T getRepository(Class<T> repositoryInterface, Object customImplementation) {

    RepositoryMetadata metadata = getRepositoryMetadata(repositoryInterface);
    Class<?> customImplementationClass = null == customImplementation ? null : customImplementation.getClass();
    RepositoryInformation information = getRepositoryInformation(metadata, customImplementationClass);

    validate(information, customImplementation);

    Object target = getTargetRepository(information);
View Full Code Here

   */
  protected RepositoryInformation getRepositoryInformation(RepositoryMetadata metadata,
      Class<?> customImplementationClass) {

    RepositoryInformationCacheKey cacheKey = new RepositoryInformationCacheKey(metadata, customImplementationClass);
    RepositoryInformation repositoryInformation = repositoryInformationCache.get(cacheKey);

    if (repositoryInformation != null) {
      return repositoryInformation;
    }

View Full Code Here

  @Test
  public void discoversCustomlyImplementedCrudMethod() throws SecurityException, NoSuchMethodException {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(FooRepository.class);
    RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class,
        customImplementation.getClass());

    Method source = FooRepositoryCustom.class.getMethod("save", User.class);
    Method expected = customImplementation.getClass().getMethod("save", User.class);

    assertThat(information.getTargetClassMethod(source), is(expected));
  }
View Full Code Here

  @Test
  public void considersIntermediateMethodsAsFinderMethods() {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(ConcreteRepository.class);
    RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, null);

    assertThat(information.hasCustomMethod(), is(false));
  }
View Full Code Here

   */
  @Test
  public void doesNotConsiderManuallyDefinedSaveMethodAQueryMethod() {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(CustomRepository.class);
    RepositoryInformation information = new DefaultRepositoryInformation(metadata, PagingAndSortingRepository.class,
        null);
    assertThat(information.getQueryMethods(), is(IsEmptyIterable.<Method> emptyIterable()));
  }
View Full Code Here

   */
  @Test
  public void doesNotConsiderRedeclaredSaveMethodAQueryMethod() throws Exception {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(ConcreteRepository.class);
    RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, null);

    Method saveMethod = BaseRepository.class.getMethod("save", Object.class);
    Method deleteMethod = BaseRepository.class.getMethod("delete", Object.class);

    Iterable<Method> queryMethods = information.getQueryMethods();

    assertThat(queryMethods, not(hasItem(saveMethod)));
    assertThat(queryMethods, not(hasItem(deleteMethod)));
  }
View Full Code Here

  @Test
  public void onlyReturnsMostConcreteQueryMethod() throws Exception {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(ConcreteRepository.class);
    RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, null);

    Method intermediateMethod = BaseRepository.class.getMethod("genericMethodToOverride", String.class);
    Method concreteMethod = ConcreteRepository.class.getMethod("genericMethodToOverride", String.class);

    Iterable<Method> queryMethods = information.getQueryMethods();

    assertThat(queryMethods, hasItem(concreteMethod));
    assertThat(queryMethods, not(hasItem(intermediateMethod)));
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.repository.core.RepositoryInformation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.