How to use JPA metamodel with gradle, intellij IDEA?












0















I am using java 8, spring boot 2.0.0, spring-data-jpa(spring-boot-starter-data-jpa), gradle, intellij. I've been trying to use JPA Metamodel, but having difficulty on finding how to configure.



Metamodels for Entity classes aren't just generated.



I guessed it would be simple, but now it seems that can be wrong. How can I use it?










share|improve this question























  • This link seems helpful, maybe you can use this method blog.trinnovative.de/2016/02/09/generate-jpa-metamodel

    – Emil Hotkowski
    Apr 14 '18 at 13:46
















0















I am using java 8, spring boot 2.0.0, spring-data-jpa(spring-boot-starter-data-jpa), gradle, intellij. I've been trying to use JPA Metamodel, but having difficulty on finding how to configure.



Metamodels for Entity classes aren't just generated.



I guessed it would be simple, but now it seems that can be wrong. How can I use it?










share|improve this question























  • This link seems helpful, maybe you can use this method blog.trinnovative.de/2016/02/09/generate-jpa-metamodel

    – Emil Hotkowski
    Apr 14 '18 at 13:46














0












0








0








I am using java 8, spring boot 2.0.0, spring-data-jpa(spring-boot-starter-data-jpa), gradle, intellij. I've been trying to use JPA Metamodel, but having difficulty on finding how to configure.



Metamodels for Entity classes aren't just generated.



I guessed it would be simple, but now it seems that can be wrong. How can I use it?










share|improve this question














I am using java 8, spring boot 2.0.0, spring-data-jpa(spring-boot-starter-data-jpa), gradle, intellij. I've been trying to use JPA Metamodel, but having difficulty on finding how to configure.



Metamodels for Entity classes aren't just generated.



I guessed it would be simple, but now it seems that can be wrong. How can I use it?







spring-boot jpa gradle intellij-idea metamodel






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 14 '18 at 9:53









jjanggajjangga

214




214













  • This link seems helpful, maybe you can use this method blog.trinnovative.de/2016/02/09/generate-jpa-metamodel

    – Emil Hotkowski
    Apr 14 '18 at 13:46



















  • This link seems helpful, maybe you can use this method blog.trinnovative.de/2016/02/09/generate-jpa-metamodel

    – Emil Hotkowski
    Apr 14 '18 at 13:46

















This link seems helpful, maybe you can use this method blog.trinnovative.de/2016/02/09/generate-jpa-metamodel

– Emil Hotkowski
Apr 14 '18 at 13:46





This link seems helpful, maybe you can use this method blog.trinnovative.de/2016/02/09/generate-jpa-metamodel

– Emil Hotkowski
Apr 14 '18 at 13:46












2 Answers
2






active

oldest

votes


















0














I did this the other day using the scalified metamodel gradle plugin (https://plugins.gradle.org/plugin/com.scalified.plugins.gradle.metamodel). I'm using Spring Boot 2.0.5, but I don't see why it wouldn't work the same with Spring Boot 2.0.0. I'm using Gradle 4.8.1 as well.



Below is an excerpt of my build.gradle.



buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath (
"org.springframework.boot:spring-boot-gradle-plugin:2.0.0",
"gradle.plugin.com.scalified.plugins.gradle:metamodel:0.0.1");
}
}

apply plugin: "com.scalified.plugins.gradle.metamodel"

// The plugin will default to the latest version of Hibernate if this is not specified
metamodel {
hibernateVersion = '5.2.14.Final' // For Spring Boot 2.0.0
hibernateVersion = '5.2.17.Final' // For Spring Boot 2.0.5
}


This builds the metamodal files under src/generated and they can be used in your code. I had to also change an IntelliJ setting because IntelliJ's Build Automatically excludes some Gradle tasks that could be long running. See Automatically run Gradle task in project build with IntelliJ IDEA and https://youtrack.jetbrains.com/issue/IDEA-175165 for more details.



This setting I changed to overcome this is: Preferences->Build/Execution/Deployment->Gradle->Runner->Delegate IDE build/run actions to Gradle. An alternative would be to run the metamodelCompile gradle task manually as needed. That would lessen the time to rebuild by a little if you aren't frequently change your entities.






share|improve this answer































    0














    JDK11 / Gradle 5.0 / Hibernate 5.3.7.Final



    sourceSets.main.java.srcDirs += "${buildDir}/generated"

    compileJava {
    options.annotationProcessorGeneratedSourcesDirectory = file("${buildDir}/generated")
    }

    dependencies {
    annotationProcessor("javax.xml.bind:jaxb-api")
    annotationProcessor("org.hibernate:hibernate-jpamodelgen")
    }


    Generated Metamodel classes will be generated at 'build/generated'



    If you are using JDK8, annotationProcessor("javax.xml.bind:jaxb-api") may unnecessary.






    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49830187%2fhow-to-use-jpa-metamodel-with-gradle-intellij-idea%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      I did this the other day using the scalified metamodel gradle plugin (https://plugins.gradle.org/plugin/com.scalified.plugins.gradle.metamodel). I'm using Spring Boot 2.0.5, but I don't see why it wouldn't work the same with Spring Boot 2.0.0. I'm using Gradle 4.8.1 as well.



      Below is an excerpt of my build.gradle.



      buildscript {
      repositories {
      maven {
      url "https://plugins.gradle.org/m2/"
      }
      }
      dependencies {
      classpath (
      "org.springframework.boot:spring-boot-gradle-plugin:2.0.0",
      "gradle.plugin.com.scalified.plugins.gradle:metamodel:0.0.1");
      }
      }

      apply plugin: "com.scalified.plugins.gradle.metamodel"

      // The plugin will default to the latest version of Hibernate if this is not specified
      metamodel {
      hibernateVersion = '5.2.14.Final' // For Spring Boot 2.0.0
      hibernateVersion = '5.2.17.Final' // For Spring Boot 2.0.5
      }


      This builds the metamodal files under src/generated and they can be used in your code. I had to also change an IntelliJ setting because IntelliJ's Build Automatically excludes some Gradle tasks that could be long running. See Automatically run Gradle task in project build with IntelliJ IDEA and https://youtrack.jetbrains.com/issue/IDEA-175165 for more details.



      This setting I changed to overcome this is: Preferences->Build/Execution/Deployment->Gradle->Runner->Delegate IDE build/run actions to Gradle. An alternative would be to run the metamodelCompile gradle task manually as needed. That would lessen the time to rebuild by a little if you aren't frequently change your entities.






      share|improve this answer




























        0














        I did this the other day using the scalified metamodel gradle plugin (https://plugins.gradle.org/plugin/com.scalified.plugins.gradle.metamodel). I'm using Spring Boot 2.0.5, but I don't see why it wouldn't work the same with Spring Boot 2.0.0. I'm using Gradle 4.8.1 as well.



        Below is an excerpt of my build.gradle.



        buildscript {
        repositories {
        maven {
        url "https://plugins.gradle.org/m2/"
        }
        }
        dependencies {
        classpath (
        "org.springframework.boot:spring-boot-gradle-plugin:2.0.0",
        "gradle.plugin.com.scalified.plugins.gradle:metamodel:0.0.1");
        }
        }

        apply plugin: "com.scalified.plugins.gradle.metamodel"

        // The plugin will default to the latest version of Hibernate if this is not specified
        metamodel {
        hibernateVersion = '5.2.14.Final' // For Spring Boot 2.0.0
        hibernateVersion = '5.2.17.Final' // For Spring Boot 2.0.5
        }


        This builds the metamodal files under src/generated and they can be used in your code. I had to also change an IntelliJ setting because IntelliJ's Build Automatically excludes some Gradle tasks that could be long running. See Automatically run Gradle task in project build with IntelliJ IDEA and https://youtrack.jetbrains.com/issue/IDEA-175165 for more details.



        This setting I changed to overcome this is: Preferences->Build/Execution/Deployment->Gradle->Runner->Delegate IDE build/run actions to Gradle. An alternative would be to run the metamodelCompile gradle task manually as needed. That would lessen the time to rebuild by a little if you aren't frequently change your entities.






        share|improve this answer


























          0












          0








          0







          I did this the other day using the scalified metamodel gradle plugin (https://plugins.gradle.org/plugin/com.scalified.plugins.gradle.metamodel). I'm using Spring Boot 2.0.5, but I don't see why it wouldn't work the same with Spring Boot 2.0.0. I'm using Gradle 4.8.1 as well.



          Below is an excerpt of my build.gradle.



          buildscript {
          repositories {
          maven {
          url "https://plugins.gradle.org/m2/"
          }
          }
          dependencies {
          classpath (
          "org.springframework.boot:spring-boot-gradle-plugin:2.0.0",
          "gradle.plugin.com.scalified.plugins.gradle:metamodel:0.0.1");
          }
          }

          apply plugin: "com.scalified.plugins.gradle.metamodel"

          // The plugin will default to the latest version of Hibernate if this is not specified
          metamodel {
          hibernateVersion = '5.2.14.Final' // For Spring Boot 2.0.0
          hibernateVersion = '5.2.17.Final' // For Spring Boot 2.0.5
          }


          This builds the metamodal files under src/generated and they can be used in your code. I had to also change an IntelliJ setting because IntelliJ's Build Automatically excludes some Gradle tasks that could be long running. See Automatically run Gradle task in project build with IntelliJ IDEA and https://youtrack.jetbrains.com/issue/IDEA-175165 for more details.



          This setting I changed to overcome this is: Preferences->Build/Execution/Deployment->Gradle->Runner->Delegate IDE build/run actions to Gradle. An alternative would be to run the metamodelCompile gradle task manually as needed. That would lessen the time to rebuild by a little if you aren't frequently change your entities.






          share|improve this answer













          I did this the other day using the scalified metamodel gradle plugin (https://plugins.gradle.org/plugin/com.scalified.plugins.gradle.metamodel). I'm using Spring Boot 2.0.5, but I don't see why it wouldn't work the same with Spring Boot 2.0.0. I'm using Gradle 4.8.1 as well.



          Below is an excerpt of my build.gradle.



          buildscript {
          repositories {
          maven {
          url "https://plugins.gradle.org/m2/"
          }
          }
          dependencies {
          classpath (
          "org.springframework.boot:spring-boot-gradle-plugin:2.0.0",
          "gradle.plugin.com.scalified.plugins.gradle:metamodel:0.0.1");
          }
          }

          apply plugin: "com.scalified.plugins.gradle.metamodel"

          // The plugin will default to the latest version of Hibernate if this is not specified
          metamodel {
          hibernateVersion = '5.2.14.Final' // For Spring Boot 2.0.0
          hibernateVersion = '5.2.17.Final' // For Spring Boot 2.0.5
          }


          This builds the metamodal files under src/generated and they can be used in your code. I had to also change an IntelliJ setting because IntelliJ's Build Automatically excludes some Gradle tasks that could be long running. See Automatically run Gradle task in project build with IntelliJ IDEA and https://youtrack.jetbrains.com/issue/IDEA-175165 for more details.



          This setting I changed to overcome this is: Preferences->Build/Execution/Deployment->Gradle->Runner->Delegate IDE build/run actions to Gradle. An alternative would be to run the metamodelCompile gradle task manually as needed. That would lessen the time to rebuild by a little if you aren't frequently change your entities.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 '18 at 17:31









          PCalouchePCalouche

          765614




          765614

























              0














              JDK11 / Gradle 5.0 / Hibernate 5.3.7.Final



              sourceSets.main.java.srcDirs += "${buildDir}/generated"

              compileJava {
              options.annotationProcessorGeneratedSourcesDirectory = file("${buildDir}/generated")
              }

              dependencies {
              annotationProcessor("javax.xml.bind:jaxb-api")
              annotationProcessor("org.hibernate:hibernate-jpamodelgen")
              }


              Generated Metamodel classes will be generated at 'build/generated'



              If you are using JDK8, annotationProcessor("javax.xml.bind:jaxb-api") may unnecessary.






              share|improve this answer






























                0














                JDK11 / Gradle 5.0 / Hibernate 5.3.7.Final



                sourceSets.main.java.srcDirs += "${buildDir}/generated"

                compileJava {
                options.annotationProcessorGeneratedSourcesDirectory = file("${buildDir}/generated")
                }

                dependencies {
                annotationProcessor("javax.xml.bind:jaxb-api")
                annotationProcessor("org.hibernate:hibernate-jpamodelgen")
                }


                Generated Metamodel classes will be generated at 'build/generated'



                If you are using JDK8, annotationProcessor("javax.xml.bind:jaxb-api") may unnecessary.






                share|improve this answer




























                  0












                  0








                  0







                  JDK11 / Gradle 5.0 / Hibernate 5.3.7.Final



                  sourceSets.main.java.srcDirs += "${buildDir}/generated"

                  compileJava {
                  options.annotationProcessorGeneratedSourcesDirectory = file("${buildDir}/generated")
                  }

                  dependencies {
                  annotationProcessor("javax.xml.bind:jaxb-api")
                  annotationProcessor("org.hibernate:hibernate-jpamodelgen")
                  }


                  Generated Metamodel classes will be generated at 'build/generated'



                  If you are using JDK8, annotationProcessor("javax.xml.bind:jaxb-api") may unnecessary.






                  share|improve this answer















                  JDK11 / Gradle 5.0 / Hibernate 5.3.7.Final



                  sourceSets.main.java.srcDirs += "${buildDir}/generated"

                  compileJava {
                  options.annotationProcessorGeneratedSourcesDirectory = file("${buildDir}/generated")
                  }

                  dependencies {
                  annotationProcessor("javax.xml.bind:jaxb-api")
                  annotationProcessor("org.hibernate:hibernate-jpamodelgen")
                  }


                  Generated Metamodel classes will be generated at 'build/generated'



                  If you are using JDK8, annotationProcessor("javax.xml.bind:jaxb-api") may unnecessary.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Dec 7 '18 at 3:21

























                  answered Dec 6 '18 at 12:18









                  Yuki YoshidaYuki Yoshida

                  935922




                  935922






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49830187%2fhow-to-use-jpa-metamodel-with-gradle-intellij-idea%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      How to change which sound is reproduced for terminal bell?

                      Can I use Tabulator js library in my java Spring + Thymeleaf project?

                      Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents