Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryByExampleExecutor support not available [DATAREDIS-895] #1467

Closed
spring-projects-issues opened this issue Nov 23, 2018 · 1 comment
Closed
Assignees
Labels
status: invalid An issue that we don't feel is valid

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Nov 23, 2018

Lax opened DATAREDIS-895 and commented

I am getting below error when I am trying to implement the QueryByExampleExecutor

java.lang.IllegalStateException: Failed to execute CommandLineRunner

at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]

at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:776) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]

at com.example.RedisExampleApplication.main(RedisExampleApplication.java:19) [classes/:na]

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property count found for type User!

at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:94) ~[spring-data-commons-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:358) ~[spring-data-commons-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:334) ~[spring-data-commons-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:287) ~[spring-data-commons-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at java.util.concurrent.ConcurrentMap.computeIfAbsent(Unknown Source) ~[na:1.8.0_162]

at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:269) ~[spring-data-commons-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:252) ~[spring-data-commons-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at org.springframework.data.repository.query.parser.Part.<init>(Part.java:81) ~[spring-data-commons-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at org.springframework.data.repository.query.parser.PartTree$OrPart.lambda$new$0(PartTree.java:250) ~[spring-data-commons-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) ~[na:1.8.0_162]

at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) ~[na:1.8.0_162]

at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source) ~[na:1.8.0_162]

at java.util.stream.AbstractPipeline.copyInto(Unknown Source) ~[na:1.8.0_162]

at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) ~[na:1.8.0_162]

at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source) ~[na:1.8.0_162]

at java.util.stream.AbstractPipeline.evaluate(Unknown Source) ~[na:1.8.0_162]

at java.util.stream.ReferencePipeline.collect(Unknown Source) ~[na:1.8.0_162]

at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:251) ~[spring-data-commons-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at org.springframework.data.repository.query.parser.PartTree$Predicate.lambda$new$0(PartTree.java:380) ~[spring-data-commons-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) ~[na:1.8.0_162]

at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) ~[na:1.8.0_162]

at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source) ~[na:1.8.0_162]

at java.util.stream.AbstractPipeline.copyInto(Unknown Source) ~[na:1.8.0_162]

at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) ~[na:1.8.0_162]

at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source) ~[na:1.8.0_162]

at java.util.stream.AbstractPipeline.evaluate(Unknown Source) ~[na:1.8.0_162]

at java.util.stream.ReferencePipeline.collect(Unknown Source) ~[na:1.8.0_162]

at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:381) ~[spring-data-commons-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:93) ~[spring-data-commons-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery.createQuery(KeyValuePartTreeQuery.java:206) ~[spring-data-keyvalue-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery.prepareQuery(KeyValuePartTreeQuery.java:148) ~[spring-data-keyvalue-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery.execute(KeyValuePartTreeQuery.java:106) ~[spring-data-keyvalue-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:602) ~[spring-data-commons-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:590) ~[spring-data-commons-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.10.RELEASE.jar:5.0.10.RELEASE]

at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59) ~[spring-data-commons-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.10.RELEASE.jar:5.0.10.RELEASE]

at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-5.0.10.RELEASE.jar:5.0.10.RELEASE]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.10.RELEASE.jar:5.0.10.RELEASE]

at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61) ~[spring-data-commons-2.0.11.RELEASE.jar:2.0.11.RELEASE]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.10.RELEASE.jar:5.0.10.RELEASE]

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.0.10.RELEASE.jar:5.0.10.RELEASE]

at com.sun.proxy.$Proxy60.count(Unknown Source) ~[na:na]

at com.example.RedisExampleApplication.run(RedisExampleApplication.java:30) [classes/:na]

at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:792) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]

... 5 common frames omitted

I used below model & code

User.java 

@Data
@NoArgsConstructor(force = true)
@RequiredArgsConstructor
@RedisHash(value="user")
public class User {
    private @Id Long id;
    @Indexed
    private final String firstname;
    private final String lastname;
    private final Integer age;
}

 SpecialUser.java

public class SpecialUser extends User {
   public SpecialUser(String firstname, String lastname, Integer age) {
        super(firstname, lastname, 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", "White", 45));
     User walter = userRepository.save(new SpecialUser("Walter", "White", 50));
     User flynn = userRepository.save(new SpecialUser("Walter Jr. (Flynn)", "White", 17));
userRepository.saveAll(Arrays.asList(skyler, walter, flynn));
 
long count = userRepository.count(Example.of(new User(null, "White", null)));
System.out.println("COUNT ? "+count);
}
}

 

 

 

 

 

 

 

 

 


Issue Links:

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Feb 8, 2019

Mark Paluch commented

Query by Example is supported as of version 2.1. The stack trace indicates that you're using version 2.0 of Spring Data Redis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

2 participants