Caused by: org.springframework.dao.IncorrectResultSizeDataAccessException: Incorrect result size: Spring Data...












0















I am developing code by taking reference from : https://www.programcreek.com/java-api-examples/?code=Just-Fun/spring-data-examples/spring-data-examples-master/jpa/query-by-example/src/test/java/example/springdata/jpa/querybyexample/UserRepositoryIntegrationTests.java.



User.java



@Data
@RedisHash("User")
public class User {

private @Id Long id;
@Indexed
private String firstname;
@Indexed
private String lastname;
private Integer age;

public User() {}

public User(String firstname, String lastname, Integer age) {
super();
this.firstname = firstname;
this.lastname = lastname;
this.age = age;
}
}


UserRepository.java



public interface UserRepository extends QueryByExampleExecutor<User>, CrudRepository<User, String> {

}


RedisExampleApplication.java



@SpringBootApplication
public class RedisExampleApplication implements CommandLineRunner{
@Autowired
private UserRepository userRepository;

public static void main(String args) {
SpringApplication.run(RedisExampleApplication.class, args);
}

@Override
public void run(String... args) throws Exception {
userRepository.deleteAll();

User skyler = userRepository.save(new User("Skyler", "Doe", 45));
User walter = userRepository.save(new User("Walter", "White", 50));
User flynn = userRepository.save(new User("Walter Jr. (Flynn)", "Kerr", 17));
userRepository.saveAll(Arrays.asList(skyler, walter, flynn));

long count = userRepository.count(Example.of(new User(null, "White", null)));
System.out.println("COUNT ? "+count);


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

Optional<User> findOne = userRepository.findOne(example);
System.out.println("USER ? "+findOne);
}
}


Error:



java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:816) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:797) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:324) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at com.example.RedisExampleApplication.main(RedisExampleApplication.java:23) [classes/:na]
Caused by: org.springframework.dao.IncorrectResultSizeDataAccessException: Incorrect result size: expected 1
at org.springframework.data.redis.repository.support.QueryByExampleRedisExecutor.findOne(QueryByExampleRedisExecutor.java:107) ~[spring-data-redis-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_162]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_162]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_162]
at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:359) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:644) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:608) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at com.sun.proxy.$Proxy57.findOne(Unknown Source) ~[na:na]
at com.example.RedisExampleApplication.run(RedisExampleApplication.java:45) [classes/:na]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:813) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
... 5 common frames omitted









share|improve this question



























    0















    I am developing code by taking reference from : https://www.programcreek.com/java-api-examples/?code=Just-Fun/spring-data-examples/spring-data-examples-master/jpa/query-by-example/src/test/java/example/springdata/jpa/querybyexample/UserRepositoryIntegrationTests.java.



    User.java



    @Data
    @RedisHash("User")
    public class User {

    private @Id Long id;
    @Indexed
    private String firstname;
    @Indexed
    private String lastname;
    private Integer age;

    public User() {}

    public User(String firstname, String lastname, Integer age) {
    super();
    this.firstname = firstname;
    this.lastname = lastname;
    this.age = age;
    }
    }


    UserRepository.java



    public interface UserRepository extends QueryByExampleExecutor<User>, CrudRepository<User, String> {

    }


    RedisExampleApplication.java



    @SpringBootApplication
    public class RedisExampleApplication implements CommandLineRunner{
    @Autowired
    private UserRepository userRepository;

    public static void main(String args) {
    SpringApplication.run(RedisExampleApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
    userRepository.deleteAll();

    User skyler = userRepository.save(new User("Skyler", "Doe", 45));
    User walter = userRepository.save(new User("Walter", "White", 50));
    User flynn = userRepository.save(new User("Walter Jr. (Flynn)", "Kerr", 17));
    userRepository.saveAll(Arrays.asList(skyler, walter, flynn));

    long count = userRepository.count(Example.of(new User(null, "White", null)));
    System.out.println("COUNT ? "+count);


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

    Optional<User> findOne = userRepository.findOne(example);
    System.out.println("USER ? "+findOne);
    }
    }


    Error:



    java.lang.IllegalStateException: Failed to execute CommandLineRunner
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:816) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
    at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:797) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:324) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
    at com.example.RedisExampleApplication.main(RedisExampleApplication.java:23) [classes/:na]
    Caused by: org.springframework.dao.IncorrectResultSizeDataAccessException: Incorrect result size: expected 1
    at org.springframework.data.redis.repository.support.QueryByExampleRedisExecutor.findOne(QueryByExampleRedisExecutor.java:107) ~[spring-data-redis-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_162]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_162]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_162]
    at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:359) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:644) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:608) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
    at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
    at com.sun.proxy.$Proxy57.findOne(Unknown Source) ~[na:na]
    at com.example.RedisExampleApplication.run(RedisExampleApplication.java:45) [classes/:na]
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:813) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
    ... 5 common frames omitted









    share|improve this question

























      0












      0








      0


      1






      I am developing code by taking reference from : https://www.programcreek.com/java-api-examples/?code=Just-Fun/spring-data-examples/spring-data-examples-master/jpa/query-by-example/src/test/java/example/springdata/jpa/querybyexample/UserRepositoryIntegrationTests.java.



      User.java



      @Data
      @RedisHash("User")
      public class User {

      private @Id Long id;
      @Indexed
      private String firstname;
      @Indexed
      private String lastname;
      private Integer age;

      public User() {}

      public User(String firstname, String lastname, Integer age) {
      super();
      this.firstname = firstname;
      this.lastname = lastname;
      this.age = age;
      }
      }


      UserRepository.java



      public interface UserRepository extends QueryByExampleExecutor<User>, CrudRepository<User, String> {

      }


      RedisExampleApplication.java



      @SpringBootApplication
      public class RedisExampleApplication implements CommandLineRunner{
      @Autowired
      private UserRepository userRepository;

      public static void main(String args) {
      SpringApplication.run(RedisExampleApplication.class, args);
      }

      @Override
      public void run(String... args) throws Exception {
      userRepository.deleteAll();

      User skyler = userRepository.save(new User("Skyler", "Doe", 45));
      User walter = userRepository.save(new User("Walter", "White", 50));
      User flynn = userRepository.save(new User("Walter Jr. (Flynn)", "Kerr", 17));
      userRepository.saveAll(Arrays.asList(skyler, walter, flynn));

      long count = userRepository.count(Example.of(new User(null, "White", null)));
      System.out.println("COUNT ? "+count);


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

      Optional<User> findOne = userRepository.findOne(example);
      System.out.println("USER ? "+findOne);
      }
      }


      Error:



      java.lang.IllegalStateException: Failed to execute CommandLineRunner
      at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:816) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
      at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:797) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:324) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
      at com.example.RedisExampleApplication.main(RedisExampleApplication.java:23) [classes/:na]
      Caused by: org.springframework.dao.IncorrectResultSizeDataAccessException: Incorrect result size: expected 1
      at org.springframework.data.redis.repository.support.QueryByExampleRedisExecutor.findOne(QueryByExampleRedisExecutor.java:107) ~[spring-data-redis-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_162]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_162]
      at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_162]
      at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:359) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:644) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:608) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
      at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
      at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
      at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
      at com.sun.proxy.$Proxy57.findOne(Unknown Source) ~[na:na]
      at com.example.RedisExampleApplication.run(RedisExampleApplication.java:45) [classes/:na]
      at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:813) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
      ... 5 common frames omitted









      share|improve this question














      I am developing code by taking reference from : https://www.programcreek.com/java-api-examples/?code=Just-Fun/spring-data-examples/spring-data-examples-master/jpa/query-by-example/src/test/java/example/springdata/jpa/querybyexample/UserRepositoryIntegrationTests.java.



      User.java



      @Data
      @RedisHash("User")
      public class User {

      private @Id Long id;
      @Indexed
      private String firstname;
      @Indexed
      private String lastname;
      private Integer age;

      public User() {}

      public User(String firstname, String lastname, Integer age) {
      super();
      this.firstname = firstname;
      this.lastname = lastname;
      this.age = age;
      }
      }


      UserRepository.java



      public interface UserRepository extends QueryByExampleExecutor<User>, CrudRepository<User, String> {

      }


      RedisExampleApplication.java



      @SpringBootApplication
      public class RedisExampleApplication implements CommandLineRunner{
      @Autowired
      private UserRepository userRepository;

      public static void main(String args) {
      SpringApplication.run(RedisExampleApplication.class, args);
      }

      @Override
      public void run(String... args) throws Exception {
      userRepository.deleteAll();

      User skyler = userRepository.save(new User("Skyler", "Doe", 45));
      User walter = userRepository.save(new User("Walter", "White", 50));
      User flynn = userRepository.save(new User("Walter Jr. (Flynn)", "Kerr", 17));
      userRepository.saveAll(Arrays.asList(skyler, walter, flynn));

      long count = userRepository.count(Example.of(new User(null, "White", null)));
      System.out.println("COUNT ? "+count);


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

      Optional<User> findOne = userRepository.findOne(example);
      System.out.println("USER ? "+findOne);
      }
      }


      Error:



      java.lang.IllegalStateException: Failed to execute CommandLineRunner
      at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:816) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
      at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:797) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:324) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
      at com.example.RedisExampleApplication.main(RedisExampleApplication.java:23) [classes/:na]
      Caused by: org.springframework.dao.IncorrectResultSizeDataAccessException: Incorrect result size: expected 1
      at org.springframework.data.redis.repository.support.QueryByExampleRedisExecutor.findOne(QueryByExampleRedisExecutor.java:107) ~[spring-data-redis-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_162]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_162]
      at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_162]
      at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:359) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:644) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:608) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
      at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
      at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
      at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.1.2.RELEASE.jar:5.1.2.RELEASE]
      at com.sun.proxy.$Proxy57.findOne(Unknown Source) ~[na:na]
      at com.example.RedisExampleApplication.run(RedisExampleApplication.java:45) [classes/:na]
      at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:813) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
      ... 5 common frames omitted






      spring redis spring-data-redis






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 26 '18 at 5:28









      PAAPAA

      2,76422238




      2,76422238
























          1 Answer
          1






          active

          oldest

          votes


















          0














          The issue is probably due to :



          Optional<User> findOne = userRepository.findOne(example);


          Here you are using findOne method, but it seems that you are getting more than one results. Thus, either use find method or modify your search condition which ensure that you will get a single result.






          share|improve this answer
























          • I think your understanding is wrong here. By the use of findOne method, spring-data assumes that you have only one record satisfying the condition(like when you search with a primary key). If in case you get more than one record, then you face such exceptions. Note: findOne method does not filter out a single record from your result set. It excpects that your result set should have only one record

            – codeLover
            Nov 26 '18 at 5:57











          • Kindly accept the answer if you are satisfied :)

            – codeLover
            Nov 26 '18 at 6:15











          • See that is what I am trying to explain you..findOne method expects that your result should have a single record, if it has more than one record, then you face this exception. Please go through the documentaion of findOne to be more clear

            – codeLover
            Nov 26 '18 at 6:32











          • Then you need to share data as well 😊

            – codeLover
            Nov 26 '18 at 6:51











          • Whic records are you getting when you use findAll

            – codeLover
            Nov 26 '18 at 6:59











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475191%2fcaused-by-org-springframework-dao-incorrectresultsizedataaccessexception-incor%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          The issue is probably due to :



          Optional<User> findOne = userRepository.findOne(example);


          Here you are using findOne method, but it seems that you are getting more than one results. Thus, either use find method or modify your search condition which ensure that you will get a single result.






          share|improve this answer
























          • I think your understanding is wrong here. By the use of findOne method, spring-data assumes that you have only one record satisfying the condition(like when you search with a primary key). If in case you get more than one record, then you face such exceptions. Note: findOne method does not filter out a single record from your result set. It excpects that your result set should have only one record

            – codeLover
            Nov 26 '18 at 5:57











          • Kindly accept the answer if you are satisfied :)

            – codeLover
            Nov 26 '18 at 6:15











          • See that is what I am trying to explain you..findOne method expects that your result should have a single record, if it has more than one record, then you face this exception. Please go through the documentaion of findOne to be more clear

            – codeLover
            Nov 26 '18 at 6:32











          • Then you need to share data as well 😊

            – codeLover
            Nov 26 '18 at 6:51











          • Whic records are you getting when you use findAll

            – codeLover
            Nov 26 '18 at 6:59
















          0














          The issue is probably due to :



          Optional<User> findOne = userRepository.findOne(example);


          Here you are using findOne method, but it seems that you are getting more than one results. Thus, either use find method or modify your search condition which ensure that you will get a single result.






          share|improve this answer
























          • I think your understanding is wrong here. By the use of findOne method, spring-data assumes that you have only one record satisfying the condition(like when you search with a primary key). If in case you get more than one record, then you face such exceptions. Note: findOne method does not filter out a single record from your result set. It excpects that your result set should have only one record

            – codeLover
            Nov 26 '18 at 5:57











          • Kindly accept the answer if you are satisfied :)

            – codeLover
            Nov 26 '18 at 6:15











          • See that is what I am trying to explain you..findOne method expects that your result should have a single record, if it has more than one record, then you face this exception. Please go through the documentaion of findOne to be more clear

            – codeLover
            Nov 26 '18 at 6:32











          • Then you need to share data as well 😊

            – codeLover
            Nov 26 '18 at 6:51











          • Whic records are you getting when you use findAll

            – codeLover
            Nov 26 '18 at 6:59














          0












          0








          0







          The issue is probably due to :



          Optional<User> findOne = userRepository.findOne(example);


          Here you are using findOne method, but it seems that you are getting more than one results. Thus, either use find method or modify your search condition which ensure that you will get a single result.






          share|improve this answer













          The issue is probably due to :



          Optional<User> findOne = userRepository.findOne(example);


          Here you are using findOne method, but it seems that you are getting more than one results. Thus, either use find method or modify your search condition which ensure that you will get a single result.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 26 '18 at 5:45









          codeLovercodeLover

          2,2551620




          2,2551620













          • I think your understanding is wrong here. By the use of findOne method, spring-data assumes that you have only one record satisfying the condition(like when you search with a primary key). If in case you get more than one record, then you face such exceptions. Note: findOne method does not filter out a single record from your result set. It excpects that your result set should have only one record

            – codeLover
            Nov 26 '18 at 5:57











          • Kindly accept the answer if you are satisfied :)

            – codeLover
            Nov 26 '18 at 6:15











          • See that is what I am trying to explain you..findOne method expects that your result should have a single record, if it has more than one record, then you face this exception. Please go through the documentaion of findOne to be more clear

            – codeLover
            Nov 26 '18 at 6:32











          • Then you need to share data as well 😊

            – codeLover
            Nov 26 '18 at 6:51











          • Whic records are you getting when you use findAll

            – codeLover
            Nov 26 '18 at 6:59



















          • I think your understanding is wrong here. By the use of findOne method, spring-data assumes that you have only one record satisfying the condition(like when you search with a primary key). If in case you get more than one record, then you face such exceptions. Note: findOne method does not filter out a single record from your result set. It excpects that your result set should have only one record

            – codeLover
            Nov 26 '18 at 5:57











          • Kindly accept the answer if you are satisfied :)

            – codeLover
            Nov 26 '18 at 6:15











          • See that is what I am trying to explain you..findOne method expects that your result should have a single record, if it has more than one record, then you face this exception. Please go through the documentaion of findOne to be more clear

            – codeLover
            Nov 26 '18 at 6:32











          • Then you need to share data as well 😊

            – codeLover
            Nov 26 '18 at 6:51











          • Whic records are you getting when you use findAll

            – codeLover
            Nov 26 '18 at 6:59

















          I think your understanding is wrong here. By the use of findOne method, spring-data assumes that you have only one record satisfying the condition(like when you search with a primary key). If in case you get more than one record, then you face such exceptions. Note: findOne method does not filter out a single record from your result set. It excpects that your result set should have only one record

          – codeLover
          Nov 26 '18 at 5:57





          I think your understanding is wrong here. By the use of findOne method, spring-data assumes that you have only one record satisfying the condition(like when you search with a primary key). If in case you get more than one record, then you face such exceptions. Note: findOne method does not filter out a single record from your result set. It excpects that your result set should have only one record

          – codeLover
          Nov 26 '18 at 5:57













          Kindly accept the answer if you are satisfied :)

          – codeLover
          Nov 26 '18 at 6:15





          Kindly accept the answer if you are satisfied :)

          – codeLover
          Nov 26 '18 at 6:15













          See that is what I am trying to explain you..findOne method expects that your result should have a single record, if it has more than one record, then you face this exception. Please go through the documentaion of findOne to be more clear

          – codeLover
          Nov 26 '18 at 6:32





          See that is what I am trying to explain you..findOne method expects that your result should have a single record, if it has more than one record, then you face this exception. Please go through the documentaion of findOne to be more clear

          – codeLover
          Nov 26 '18 at 6:32













          Then you need to share data as well 😊

          – codeLover
          Nov 26 '18 at 6:51





          Then you need to share data as well 😊

          – codeLover
          Nov 26 '18 at 6:51













          Whic records are you getting when you use findAll

          – codeLover
          Nov 26 '18 at 6:59





          Whic records are you getting when you use findAll

          – codeLover
          Nov 26 '18 at 6:59




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475191%2fcaused-by-org-springframework-dao-incorrectresultsizedataaccessexception-incor%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Costa Masnaga

          Fotorealismo

          Sidney Franklin