konrad-kaminski / spring-kotlin-coroutine

Kotlin coroutine support for Spring.
448 stars 69 forks source link

CoroutineCrudRepository throws PropertyReferenceException for count method #52

Open alkismavridis opened 1 year ago

alkismavridis commented 1 year ago

I just tried to convert one of my CrudRepositorys to CoroutineCrudRepository. During boot, my application throws the following error:

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

    at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:90)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:437)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:413)
    at org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:366)
    at java.base/java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:330)
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:348)
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:331)
    at org.springframework.data.repository.query.parser.Part.<init>(Part.java:81)
    at org.springframework.data.repository.query.parser.PartTree$OrPart.lambda$new$0(PartTree.java:249)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
    at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:250)
    at org.springframework.data.repository.query.parser.PartTree$Predicate.lambda$new$0(PartTree.java:383)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
    at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:384)
    at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:92)
    at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:89)
    ... 55 common frames omitted

Neither my entity nor my repository ever mentions the term "count", except from a property named crashCount. So, I do not try to override count() or anything like that. Converting back to plain CrudRepository solves the problem.

I am using org.springframework.boot:spring-boot-starter-data-jpa Version 2.6.4 and PostgressDB.

alkismavridis commented 1 year ago

On a second though, I am not sure if I posted this on the correct project. I think this belongs here. Sorry for the trouble.