2

While upgrading the application to Spring boot 3 from Spring boot 2.7.7, I am facing a problem. I am not able to generate JPA static models using hibernate-jpamodelgen:6.1.7.Final" when also using openapi-generator-cli-6.3.0 to generate code for default controllers using api.yaml.

This does not generate hibernate static JPA models:


plugins {
    id "org.springframework.boot" version "3.0.2"
    id "org.hibernate.orm" version "6.1.7.Final"
}
.
.
.

dependencies {
    annotationProcessor "org.hibernate.orm:hibernate-jpamodelgen:6.1.7.Final"

    antlr group: 'org.antlr', name: 'antlr4', version: '4.11.1'
.
.
.
.
.


    testAnnotationProcessor "org.hibernate.orm:hibernate-jpamodelgen:6.1.7.Final"

  
.
.
.
.

    swaggerCodegen group: 'org.openapitools', name: 'openapi-generator-cli', version: '6.3.0'

}

compileJava {
    dependsOn = ['generateSwaggerCode', 'generateGrammarSource']
    excludes = ['**/TestController.java']
}

This works fine when I use swagger-codegen-cli-3.0.40.jar to generate code but JPA static model stops working without any error when used with openapi-generator-cli-6.3.0

Below code works fine:


plugins {
    id "org.springframework.boot" version "3.0.2"
    id "org.hibernate.orm" version "6.1.7.Final"
}
.
.
.

dependencies {
        annotationProcessor "org.hibernate.orm:hibernate-jpamodelgen:6.1.7.Final"


    antlr group: 'org.antlr', name: 'antlr4', version: '4.11.1'
.
.
.
.
.

    testAnnotationProcessor "org.hibernate.orm:hibernate-jpamodelgen:6.1.7.Final"

  
.
.
.
.

    swaggerCodegen group: 'io.swagger.codegen.v3', name: 'swagger-codegen-cli', version: '3.0.40'
    swaggerCodegen group: 'io.swagger.codegen.v3', name: 'swagger-codegen-generators', version: '1.0.37'
}

compileJava {
    dependsOn = ['generateSwaggerCode', 'generateGrammarSource']
    excludes = ['**/TestController.java']
}
jeet427
  • 538
  • 3
  • 16
  • Did you try running with `--debug` or `--stacktrace` already to see possible errors? – Christian Beikov Feb 20 '23 at 07:15
  • I did but could not see any related error logs. Looks like this annotationProcessor is not even invoked when openapi code generator on class path. – jeet427 Feb 27 '23 at 03:59
  • Maybe the openapi AP resolves a symbol that runs into compilation errors because the Hibernate AP hasn't run yet. Not sure how to tell Gradle the order of APs, but for `javac` the order of AP names on the command line does that job. – Christian Beikov Feb 27 '23 at 11:31
  • That's possible. Thanks Christian Beikov, let me try to find something. – jeet427 Feb 28 '23 at 07:54
  • Sharing a minimal reproducible example might get you the answer faster. – dekkard Feb 28 '23 at 20:14
  • Just to conclude this, this has been automatically fixed without any change after upgrade to annotationProcessor "org.hibernate.orm:hibernate-jpamodelgen:6.2.0.Final" – jeet427 Apr 10 '23 at 12:05

0 Answers0