spring-data-commons icon indicating copy to clipboard operation
spring-data-commons copied to clipboard

Support QueryDsl options in SimpleEntityPathResolver [DATACMNS-1658]

Open spring-projects-issues opened this issue 5 years ago • 1 comments

rob-valor opened DATACMNS-1658 and commented

QueryDsl has 3 options for defining the generated "Q" classes:

  • querydsl.prefix: override the prefix for query types(default: Q)
  • querydsl.suffix: set a suffix for query types
  • querydsl.packageSuffix: set a suffix for query type packages

org.springframework.data.querydsl.SimpleEntityPathResolver only supports configuration of querySuffix (querydsl.packageSuffix). The default querydsl.prefix is hardcoded in SimpleEntityPathResolver which prevents us from using that option. Please provide overloaded constructor(s) to align on the QueryDsl naming capabilities.

One of the problems is that Jacoco is complaining about non covered code. At the QueryDsl side there is actually the possibility to "drive" the code generation is a way that is Jacoco friendly. However, the issue with SimpleEntityPathResolver is that only the package can be customized which has a "devastating" impact on our Entities visibility because they are package private. So setting the querySuffix of SimpleEntityPathResolver is not an option. We could of course implement our own EntityPathResolver but to me it looks like a simple org.springframework.data.querydsl.EntityPathResolver could perfectly support those 3 options of QueryDsl.

That way we can have a simple ignore rule for classes starting with our prefix (or ending with a suffix)


Affects: 2.2.4 (Moore SR4)

spring-projects-issues avatar Jan 22 '20 16:01 spring-projects-issues

@odrotbohm, in querydsl (v5) I added the possibility to add a @Generated annotation with CLASS retention to allow Jacoco see the querydsl generated code. That change makes this issue obsolete because I can use Spring, querydsl and jacoco in a default way by just adding <querydsl.generatedAnnotationClass>com.querydsl.core.annotations.Generated</querydsl.generatedAnnotationClass> to the APT options

Therefore it's fine for me you close this issue.

rob-valor avatar Oct 25 '21 07:10 rob-valor