Package org.springframework.data.repository.core

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


  @SuppressWarnings({ "rawtypes", "unchecked" })
  private static RepositoryInvoker getInvokerFor(Object repository, VerifyingMethodInterceptor interceptor) {

    Object proxy = getVerifyingRepositoryProxy(repository, interceptor);

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(repository.getClass().getInterfaces()[0]);
    GenericConversionService conversionService = new DefaultFormattingConversionService();

    return new CrudRepositoryInvoker((CrudRepository) proxy, metadata, conversionService);
  }
View Full Code Here


   * @return
   */
  @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);

View Full Code Here

   * @return
   * @since 1.9
   */
  protected boolean isStrictRepositoryCandidate(Class<?> repositoryInterface) {

    RepositoryMetadata metadata = AbstractRepositoryMetadata.getMetadata(repositoryInterface);

    Collection<Class<?>> types = getIdentifyingTypes();

    for (Class<?> type : types) {
      if (type.isAssignableFrom(repositoryInterface)) {
        return true;
      }
    }

    Class<?> domainType = metadata.getDomainType();
    Collection<Class<? extends Annotation>> annotations = getIdentifyingAnnotations();

    if (annotations.isEmpty()) {
      return true;
    }
View Full Code Here

  }

  @SuppressWarnings({ "unchecked", "rawtypes" })
  private static RepositoryInvoker getInvokerFor(Object repository) {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(repository.getClass().getInterfaces()[0]);
    GenericConversionService conversionService = new DefaultFormattingConversionService();

    return new PagingAndSortingRepositoryInvoker((PagingAndSortingRepository) repository, metadata, conversionService);
  }
View Full Code Here

   * @see DATACMNS-397
   */
  @Test
  public void detectsSliceMethod() throws Exception {

    RepositoryMetadata repositoryMetadata = new DefaultRepositoryMetadata(SampleRepository.class);
    Method method = SampleRepository.class.getMethod("sliceOfUsers");
    QueryMethod queryMethod = new QueryMethod(method, repositoryMetadata);

    assertThat(queryMethod.isSliceQuery(), is(true));
    assertThat(queryMethod.isCollectionQuery(), is(false));
View Full Code Here

   * @see DATACMNS-471
   */
  @Test
  public void detectsCollectionMethodForArrayRetrunType() throws Exception {

    RepositoryMetadata repositoryMetadata = new DefaultRepositoryMetadata(SampleRepository.class);
    Method method = SampleRepository.class.getMethod("arrayOfUsers");

    assertThat(new QueryMethod(method, repositoryMetadata).isCollectionQuery(), is(true));
  }
View Full Code Here

    invoker.invokeSave(new Object());
  }

  private static RepositoryInvoker getInvokerFor(Object repository) {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(repository.getClass().getInterfaces()[0]);
    GenericConversionService conversionService = new DefaultFormattingConversionService();

    return new ReflectionRepositoryInvoker(repository, metadata, conversionService);
  }
View Full Code Here

  }

  @Test
  public void looksUpDomainClassCorrectly() throws Exception {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(UserRepository.class);
    assertEquals(User.class, metadata.getDomainType());

    metadata = new DefaultRepositoryMetadata(SomeDao.class);
    assertEquals(User.class, metadata.getDomainType());
  }
View Full Code Here

  }

  @Test
  public void findsDomainClassOnExtensionOfDaoInterface() throws Exception {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(ExtensionOfUserCustomExtendedDao.class);
    assertEquals(User.class, metadata.getDomainType());
  }
View Full Code Here

  }

  @Test
  public void detectsParameterizedEntitiesCorrectly() {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(GenericEntityRepository.class);
    assertEquals(GenericEntity.class, metadata.getDomainType());
  }
View Full Code Here

TOP

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

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.