Package org.springframework.data.repository.core.support

Examples of org.springframework.data.repository.core.support.DefaultRepositoryMetadata


  @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


    private final RepositoryMetadata repositoryMetadata;
    private final SampleMappingContext mappingContext;

    public SampleRepoFactoryInformation(Class<?> repositoryInterface) {
      this.repositoryMetadata = new DefaultRepositoryMetadata(repositoryInterface);
      this.mappingContext = new SampleMappingContext();
    }
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 testname() {

    JpaQueryMethod method = new JpaQueryMethod(repositoryMethod, new DefaultRepositoryMetadata(UserRepository.class),
        extractor);

    assertEquals("User.findByLastname", method.getNamedQueryName());
    assertThat(method.isCollectionQuery(), is(true));
    assertThat(method.getAnnotatedQuery(), is(nullValue()));
View Full Code Here

  }

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

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(UserRepository.class);

    JpaQueryMethod queryMethod = new JpaQueryMethod(repositoryMethod, metadata, extractor);
    assertThat(queryMethod.getNamedQueryName(), is("User.findByLastname"));

    Method method = UserRepository.class.getMethod("renameAllUsersTo", String.class);
View Full Code Here

  public void invalidAnnotatedQueryCausesException() throws Exception {

    QueryLookupStrategy strategy = JpaQueryLookupStrategy.create(em, Key.CREATE_IF_NOT_FOUND, extractor,
        DefaultEvaluationContextProvider.INSTANCE);
    Method method = UserRepository.class.getMethod("findByFoo", String.class);
    RepositoryMetadata metadata = new DefaultRepositoryMetadata(UserRepository.class);

    Throwable reference = new RuntimeException();
    when(em.createQuery(anyString())).thenThrow(reference);

    try {
View Full Code Here

  public void sholdThrowMorePreciseExceptionIfTryingToUsePaginationInNativeQueries() throws Exception {

    QueryLookupStrategy strategy = JpaQueryLookupStrategy.create(em, Key.CREATE_IF_NOT_FOUND, extractor,
        DefaultEvaluationContextProvider.INSTANCE);
    Method method = UserRepository.class.getMethod("findByInvalidNativeQuery", String.class, Pageable.class);
    RepositoryMetadata metadata = new DefaultRepositoryMetadata(UserRepository.class);

    exception.expect(InvalidJpaQueryMethodException.class);
    exception.expectMessage("Cannot use native queries with dynamic sorting and/or pagination in method");
    exception.expectMessage(method.toString());
View Full Code Here

TOP

Related Classes of org.springframework.data.repository.core.support.DefaultRepositoryMetadata

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.