I am using the Querydsl extension (QueryDslPredicateExecutor
) to my CrudRepository
.
To reliably exclude the generated Q
classes from my test coverage measurements, they are generated into a dedicated querydsl
subpackage of the respective domain classes (annotation processor option -Aquerydsl.packageSuffix=.querydsl
).
Alas, this causes a ClassNotFoundException
at application start up:
java.lang.IllegalArgumentException: Did not find a query class org.example.QDomain for domain class org.example.Domain!
at org.springframework.data.querydsl.SimpleEntityPathResolver.createPath(SimpleEntityPathResolver.java:63)
at org.springframework.data.mongodb.repository.support.QueryDslMongoRepository.<init>(QueryDslMongoRepository.java:85)
at org.springframework.data.mongodb.repository.support.QueryDslMongoRepository.<init>(QueryDslMongoRepository.java:67)
…
Caused by: java.lang.ClassNotFoundException: org.example.QDomain
…
I have already located the EntityPathResolver
interface that supposedly would allow me to plug in my own domain class to Q
class mapping that inserts the .querydsl
package suffix, but I haven’t found a way to configure Spring Data’s MongoRepositoryFactory
to pick my own EntityPathResolver
.
Is this possible?
Currently, the only way is to create your own variant of the MongoRepositoryFactory
because the instance of the EntityPathResolver
is hard-wired into it.