Closed dmanix closed 2 years ago
From what I can see in code - it should work. How are you providing options to the annotation processor?
I was doing it in some different ways, two examples of maven snippets below:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<generatedSourcesDirectory>${project.build.directory}/generated-sources/annotations/</generatedSourcesDirectory>
<annotationProcessors>
<annotationProcessor>
com.infobip.spring.data.jdbc.annotation.processor.SpringDataJdbcAnnotationProcessor
</annotationProcessor>
</annotationProcessors>
<compilerArgs>
<arg>-Aquerydsl.generatedAnnotationClass=javax.annotation.Generated</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/target/generated-sources/annotations</outputDirectory>
<processor>com.infobip.spring.data.jdbc.annotation.processor.SpringDataJdbcAnnotationProcessor</processor>
<options>
<querydsl.generatedAnnotationClass>javax.annotation.Generated</querydsl.generatedAnnotationClass>
</options>
</configuration>
</execution>
</executions>
</plugin>
I am pretty sure these options are recognized by processor (in both cases) as while I run it under debugger, they are included in Options Map: processingEnv.getOptions() in CustomSpringDataJdbcConfiguration constructor.
From what I looked at the code I noticed that these options are passed to CodegenModule from DefaultConfiguration but are not added to SQLCodegenModule from SpringDataJdbcConfiguration.
Support can be added. infobip-spring-data-querydsl uses both the regular CodegenModule and SQLCodegenModule. SQLCodegenModule has no code anywhere in querydsl that binds CodegenModule.GENERATED_ANNOTATION_CLASS to anything so it relies on the default it inherits from CodegenModule and that one sets it to
bindInstance(GENERATED_ANNOTATION_CLASS, GeneratedAnnotationResolver.resolveDefault());
if configure
method is invoked.
I've added this to master - https://github.com/infobip/infobip-spring-data-querydsl/commit/f73ac7f52962da96cfc80a53a52d9654d5bd1620 so let me know if this is it or you need something else.
Yes, this is exactly what I need.
BTW, I have one other question. I have a problem with setting up spring data jdbc with querydsl - I get runtime error:
org.springframework.data.repository.core.support.UnsupportedFragmentException: Repository com.atende.db.metadata.jdbcrepository.ActionRepository implements org.springframework.data.querydsl.QuerydslPredicateExecutor but JdbcRepositoryFactory does not support Querydsl!
I have described it in details on stackoverflow: https://stackoverflow.com/questions/72599490/spring-data-jdbc-querydsl-error-jdbcrepositoryfactory-does-not-support-query
Do you have any idea if I am missing anything or such use case is not supported yet in Spring data JDBC?
I've provided the full answer on stackoverflow - try removing the @EnableJdbcRepositories
first but it's likely something else is amiss. Check your classpath and check against the Spring setup that is used in jdbc module tests.
Yes, this is exactly what I need.
7.1.0 has been released. Let me know if it works.
7.1.0 has been released. Let me know if it works.
Yes, it works. Thanks!
I've provided the full answer on stackoverflow - try removing the
@EnableJdbcRepositories
first but it's likely something else is amiss. Check your classpath and check against the Spring setup that is used in jdbc module tests.
I did what you suggested but now have another problem - I have answered on stack overflow.
I am using Spring with Jdbc and QueryDSL and I'd like to use infobip-spring-data-jdbc-annotation-processor for Q-classes generation. I integrated it and it works but I noticed that QueryDSL APT options (http://querydsl.com/static/querydsl/latest/reference/html_single/#d0e2311) are not working. In particular, I need to use querydsl.generatedAnnotationClass option. Is it a bug or these options are not supported?