Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PropertyReferenceException: No property findAll found for type

Spring boot Application

I have entity Test which has both JpaRepository and ElasticSearchRepository when I use either of repositories indevidually its working fine. But when created two repositories for Test entity its throwing error bean creation error. No property findAll found for type Test!

@Data
@Table
@Entity
@Document(indexName = "test",type = "Test")
public class Test {

    @Id
    private Long id;
    @Field
    private String name;
}

public interface TestSearchRepository extends ElasticsearchRepository<Test,Long> {}

public interface FacilityRepository extends JpaRepository<Facility,Long> {}

*Error*:`eCaused by: org.springframework.data.mapping.PropertyReferenceException: No property findAll found for type Test!
    at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:85) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:309) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:289) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:248) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:215) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
    at org.springframework.data.repository.query.parser.Part.<init>(Part.java:81) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
    at org.springframework.data.repository.query.parser.PartTree$OrPart.lambda$new$0(PartTree.java:239) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[na:1.8.0_73]
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) ~[na:1.8.0_73]
    at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[na:1.8.0_73]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[na:1.8.0_73]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[na:1.8.0_73]
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[na:1.8.0_73]
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_73]
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[na:1.8.0_73]
    at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:240) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
    at org.springframework.data.repository.query.parser.PartTree$Predicate.lambda$new$0(PartTree.java:368) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[na:1.8.0_73]
    at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[na:1.8.0_73]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[na:1.8.0_73]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[na:1.8.0_73]
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[na:1.8.0_73]
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_73]
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[na:1.8.0_73]
    at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:369) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
    at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:92) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
    at org.springframework.data.elasticsearch.repository.query.ElasticsearchPartQuery.<init>(ElasticsearchPartQuery.java:46) ~[spring-data-elasticsearch-3.0.0.BUILD-20170705.074610-104.jar:na]
    at org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryFactory$ElasticsearchQueryLookupStrategy.resolveQuery(ElasticsearchRepositoryFactory.java:123) ~[spring-data-elasticsearch-3.0.0.BUILD-20170705.074610-104.jar:na]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$null$0(RepositoryFactorySupport.java:491) ~[spring-data-commons-2.0.0.BUILD-20170705.074441-111.jar:na]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[na:1.8.0_73]
    at java.util.Iterator.forEachRemaining(Iterator.java:116) ~[na:1.8.0_73]
    at java.util.Collections$UnmodifiableCollection$1.forEachRemaining(Collections.java:1049) ~[na:1.8.0_73]
    at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[na:1.8.0_73]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[na:1.8.0_73]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[na:1.8.0_73]
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[na:1.8.0_73]
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_73]
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[na:1.8.0_73]`
like image 530
Naveen Avatar asked Nov 07 '22 19:11

Naveen


1 Answers

Please try to put JPA et elasticsearch repositories in separate packages and use the following explicit configuration to avoid conflicts:

@EnableJpaRepositories("my.jpa.repositories")
@EnableElasticsearchRepositories("my.search.repositories")
like image 87
Patrice Blanchardie Avatar answered Dec 09 '22 20:12

Patrice Blanchardie