darrachequesne / spring-data-jpa-datatables

Spring Data JPA extension to work with the great jQuery plugin DataTables (https://datatables.net/)
Apache License 2.0
440 stars 174 forks source link

No property 'findAll' found for type 'Class' #151

Open rezanbt opened 1 year ago

rezanbt commented 1 year ago

hello everybody, i have problem when use this library i got this error :

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property 'findAll' found for type 'Bank'
    at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:91) ~[spring-data-commons-2.7.8.jar:2.7.8]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:438) ~[spring-data-commons-2.7.8.jar:2.7.8]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:414) ~[spring-data-commons-2.7.8.jar:2.7.8]
    at org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:367) ~[spring-data-commons-2.7.8.jar:2.7.8]
    at java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:324) ~[na:1.8.0_362]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:349) ~[spring-data-commons-2.7.8.jar:2.7.8]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:332) ~[spring-data-commons-2.7.8.jar:2.7.8]
    at org.springframework.data.repository.query.parser.Part.<init>(Part.java:81) ~[spring-data-commons-2.7.8.jar:2.7.8]
    at org.springframework.data.repository.query.parser.PartTree$OrPart.lambda$new$0(PartTree.java:250) ~[spring-data-commons-2.7.8.jar:2.7.8]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[na:1.8.0_362]
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) ~[na:1.8.0_362]
    at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[na:1.8.0_362]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[na:1.8.0_362]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[na:1.8.0_362]
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[na:1.8.0_362]
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_362]
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) ~[na:1.8.0_362]
    at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:251) ~[spring-data-commons-2.7.8.jar:2.7.8]
    at org.springframework.data.repository.query.parser.PartTree$Predicate.lambda$new$0(PartTree.java:384) ~[spring-data-commons-2.7.8.jar:2.7.8]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[na:1.8.0_362]
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) ~[na:1.8.0_362]
    at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[na:1.8.0_362]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[na:1.8.0_362]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[na:1.8.0_362]
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[na:1.8.0_362]
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_362]
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) ~[na:1.8.0_362]
    at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:385) ~[spring-data-commons-2.7.8.jar:2.7.8]
    at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:93) ~[spring-data-commons-2.7.8.jar:2.7.8]
    at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:89) ~[spring-data-jpa-2.7.8.jar:2.7.8]
    ... 75 common frames omitted

and my repository as folllow :

@Repository
public interface BankRepository extends JpaRepository<Bank, Long> , DataTablesRepository<Bank, Long> {

}

Edit: format

darrachequesne commented 1 year ago

Hi! I was not able to reproduce, which version of the library/Spring are you using?

You can find the compatibility table here: https://github.com/darrachequesne/spring-data-jpa-datatables#maven-dependency

rezanbt commented 1 year ago

Hi darrachequesne , i use spring-data-jpa-datatables version 5.2.0 with spring boot 2.7.9 with all dependencies of spring-data-jpa-datatables-samples project plus jwt + spring security

rezanbt commented 1 year ago

my pom dependency tree as follow:

[INFO] murraco:jwt-auth-service:jar:1.0.0 [INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.7.9:compile [INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.7.9:compile [INFO] | | +- org.springframework.boot:spring-boot:jar:2.7.9:compile [INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.7.9:compile [INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.7.9:compile [INFO] | | | +- ch.qos.logback:logback-classic:jar:1.2.11:compile [INFO] | | | | - ch.qos.logback:logback-core:jar:1.2.11:compile [INFO] | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.17.2:compile [INFO] | | | | - org.apache.logging.log4j:log4j-api:jar:2.17.2:compile [INFO] | | | - org.slf4j:jul-to-slf4j:jar:1.7.36:compile [INFO] | | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile [INFO] | | +- org.springframework:spring-core:jar:5.3.25:compile [INFO] | | | - org.springframework:spring-jcl:jar:5.3.25:compile [INFO] | | - org.yaml:snakeyaml:jar:1.30:compile [INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.7.9:compile [INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.13.5:compile [INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.5:compile [INFO] | | - com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.13.5:compile [INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.7.9:compile [INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.71:compile [INFO] | | - org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.71:compile [INFO] | +- org.springframework:spring-web:jar:5.3.25:compile [INFO] | | - org.springframework:spring-beans:jar:5.3.25:compile [INFO] | - org.springframework:spring-webmvc:jar:5.3.25:compile [INFO] | +- org.springframework:spring-context:jar:5.3.25:compile [INFO] | - org.springframework:spring-expression:jar:5.3.25:compile [INFO] +- org.springframework.boot:spring-boot-starter-validation:jar:2.7.9:compile [INFO] | +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.71:compile [INFO] | - org.hibernate.validator:hibernate-validator:jar:6.2.5.Final:compile [INFO] | +- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile [INFO] | - org.jboss.logging:jboss-logging:jar:3.4.3.Final:compile [INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.7.9:compile [INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:2.7.9:compile [INFO] | | - org.aspectj:aspectjweaver:jar:1.9.7:compile [INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.7.9:compile [INFO] | | +- com.zaxxer:HikariCP:jar:4.0.3:compile [INFO] | | - org.springframework:spring-jdbc:jar:5.3.25:compile [INFO] | +- jakarta.transaction:jakarta.transaction-api:jar:1.3.3:compile [INFO] | +- jakarta.persistence:jakarta.persistence-api:jar:2.2.3:compile [INFO] | +- org.hibernate:hibernate-core:jar:5.6.15.Final:compile [INFO] | | +- net.bytebuddy:byte-buddy:jar:1.12.23:compile [INFO] | | +- antlr:antlr:jar:2.7.7:compile [INFO] | | +- org.jboss:jandex:jar:2.4.2.Final:compile [INFO] | | +- org.hibernate.common:hibernate-commons-annotations:jar:5.1.2.Final:compile [INFO] | | - org.glassfish.jaxb:jaxb-runtime:jar:2.3.8:compile [INFO] | | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile [INFO] | | +- org.glassfish.jaxb:txw2:jar:2.3.8:compile [INFO] | | +- com.sun.istack:istack-commons-runtime:jar:3.0.12:compile [INFO] | | - com.sun.activation:jakarta.activation:jar:1.2.2:runtime [INFO] | +- org.springframework.data:spring-data-jpa:jar:2.7.8:compile [INFO] | | +- org.springframework.data:spring-data-commons:jar:2.7.8:compile [INFO] | | +- org.springframework:spring-orm:jar:5.3.25:compile [INFO] | | - org.springframework:spring-tx:jar:5.3.25:compile [INFO] | - org.springframework:spring-aspects:jar:5.3.25:compile [INFO] +- org.springframework.boot:spring-boot-starter-thymeleaf:jar:2.7.9:compile [INFO] | +- org.thymeleaf:thymeleaf-spring5:jar:3.0.15.RELEASE:compile [INFO] | | - org.thymeleaf:thymeleaf:jar:3.0.15.RELEASE:compile [INFO] | | +- org.attoparser:attoparser:jar:2.0.5.RELEASE:compile [INFO] | | - org.unbescape:unbescape:jar:1.1.6.RELEASE:compile [INFO] | - org.thymeleaf.extras:thymeleaf-extras-java8time:jar:3.0.4.RELEASE:compile [INFO] +- org.springframework.boot:spring-boot-starter-security:jar:2.7.9:compile [INFO] | +- org.springframework:spring-aop:jar:5.3.25:compile [INFO] | +- org.springframework.security:spring-security-config:jar:5.7.7:compile [INFO] | | - org.springframework.security:spring-security-core:jar:5.7.7:compile [INFO] | | - org.springframework.security:spring-security-crypto:jar:5.7.7:compile [INFO] | - org.springframework.security:spring-security-web:jar:5.7.7:compile [INFO] +- com.mysql:mysql-connector-j:jar:8.0.32:compile [INFO] +- com.h2database:h2:jar:2.1.214:runtime [INFO] +- org.projectlombok:lombok:jar:1.18.20:provided [INFO] +- io.springfox:springfox-swagger2:jar:2.9.2:compile [INFO] | +- io.swagger:swagger-annotations:jar:1.5.20:compile [INFO] | +- io.swagger:swagger-models:jar:1.5.20:compile [INFO] | | - com.fasterxml.jackson.core:jackson-annotations:jar:2.13.5:compile [INFO] | +- io.springfox:springfox-spi:jar:2.9.2:compile [INFO] | | - io.springfox:springfox-core:jar:2.9.2:compile [INFO] | +- io.springfox:springfox-schema:jar:2.9.2:compile [INFO] | +- io.springfox:springfox-swagger-common:jar:2.9.2:compile [INFO] | +- io.springfox:springfox-spring-web:jar:2.9.2:compile [INFO] | +- com.google.guava:guava:jar:20.0:compile [INFO] | +- com.fasterxml:classmate:jar:1.5.1:compile [INFO] | +- org.slf4j:slf4j-api:jar:1.7.36:compile [INFO] | +- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile [INFO] | +- org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile [INFO] | - org.mapstruct:mapstruct:jar:1.2.0.Final:compile [INFO] +- io.springfox:springfox-swagger-ui:jar:2.9.2:compile [INFO] +- io.jsonwebtoken:jjwt:jar:0.9.1:compile [INFO] | - com.fasterxml.jackson.core:jackson-databind:jar:2.13.5:compile [INFO] | - com.fasterxml.jackson.core:jackson-core:jar:2.13.5:compile [INFO] +- org.modelmapper:modelmapper:jar:2.4.4:compile [INFO] - com.github.darrachequesne:spring-data-jpa-datatables:jar:5.2.0:compile [INFO] +- javax.validation:validation-api:jar:2.0.1.Final:compile [INFO] +- org.hibernate:hibernate-entitymanager:jar:5.6.15.Final:compile [INFO] | +- javax.persistence:javax.persistence-api:jar:2.2:compile [INFO] | - org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.1.1.Final:compile [INFO] +- com.querydsl:querydsl-apt:jar:5.0.0:compile [INFO] | - com.querydsl:querydsl-codegen:jar:5.0.0:compile [INFO] | +- com.querydsl:codegen-utils:jar:5.0.0:compile [INFO] | | - org.eclipse.jdt:ecj:jar:3.26.0:compile [INFO] | +- javax.inject:javax.inject:jar:1:compile [INFO] | - io.github.classgraph:classgraph:jar:4.8.108:compile [INFO] +- com.querydsl:querydsl-jpa:jar:5.0.0:compile [INFO] | - com.querydsl:querydsl-core:jar:5.0.0:compile [INFO] | - com.mysema.commons:mysema-commons-lang:jar:0.2.4:compile [INFO] - javax.annotation:javax.annotation-api:jar:1.3.2:compile

lifeweaver commented 7 months ago

I had this same issue.

See https://github.com/darrachequesne/spring-data-jpa-datatables-sample/issues/2

I'll note that for me I had tried adding the @EnableJpRepositories annotation, but I kept getting the same error. But once I removed my existing @Repository annotation from the interface extending DataTablesRepostiory, the error went away.

It would be helpful to call that out in the documentation, "Don't add @Repository to your interface", etc. Or maybe have the code handle it someway so it doesn't matter, or maybe add a warn message.