Hi Jens,

This seems to be a dependency issue - a very unfortunate one at that.

We do some magic to work around some Maven limitations where project
dependencies are not automatically on the classpath of a plugin. We did
this such that users don't have to repeat adding the JDBC driver dependency
all the time. The relevant trick was implemented here:
https://github.com/jOOQ/jOOQ/issues/2886

But in this particular case, it appears that transitive dependencies cannot
be looked up this way, for example both Hibernate and the JPA API are
missing.

I can get your project to compile and generate code using this patch:

diff --git a/jooq-model/pom.xml b/jooq-model/pom.xml
index 9cfd3b9..f4fda74 100644
--- a/jooq-model/pom.xml
+++ b/jooq-model/pom.xml
@@ -45,6 +45,16 @@
                         <artifactId>spring-boot</artifactId>
                         <version>${spring.boot.version}</version>
                     </dependency>
+                    <dependency>
+                        <groupId>org.jooq</groupId>
+                        <artifactId>jooq-meta-extensions</artifactId>
+                        <version>${jooq.version}</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>javax.persistence</groupId>
+                        <artifactId>javax.persistence-api</artifactId>
+                        <version>2.2</version>
+                    </dependency>
                 </dependencies>

                 <!-- The plugin should hook into the generate goal -->
diff --git a/pom.xml b/pom.xml
index e9fd6c1..ac13a30 100644
--- a/pom.xml
+++ b/pom.xml
@@ -84,4 +84,21 @@
       <artifactId>lombok</artifactId>
     </dependency>
   </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.8.1</version>
+          <configuration>
+            <source>11</source>
+            <target>11</target>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
 </project>

This is very annoying, of course, and without significant maven-fu (who has
that) can only be achieved by randomly adding more dependencies until it
works. I tend to think that this is by design in Maven, but it may well be
that we're misunderstanding something, or that we could add another hack
like the one where we found JDBC drivers from the project classpath. In
fact, again, our workaround already managed to find jooq-meta-extensions
for you, but not its transitive dependencies.

I have created a feature request to try to solve this for a future version
of jOOQ:
https://github.com/jOOQ/jOOQ/issues/9227

I hope this helps,
Lukas

On Tue, Sep 17, 2019 at 10:57 AM Jens Teglhus Møller <j...@mostlyharmless.dk>
wrote:

> Hi
>
> I'm trying to get schema generation using JPADatabase to work with spring
> boot.
>
> In my initial testing I got everything working to the point where there
> was a mismatch with the table names when executing queries (generator not
> using same naming strategy as spring app).
>
> I have a 3 module maven setup with jpa-model, jooq-model and spring-app
> (simplified example can be seen here:
> https://github.com/djarnis73/jooq-spring-jpa-example).
>
> I saw the documentation regarding
> setting 
> hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
> but when i do that the code generator fails since it cannot find the class.
>
> [ERROR] Failed to execute goal org.jooq:jooq-codegen-maven:3.12.1:generate
> (default) on project jooq-model: Error running jOOQ code generation tool:
> Error while exporting schema: Unable to resolve name
> [org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy]
> as strategy [org.hibernate.boot.model.naming.PhysicalNamingStrategy]:
> Unable to load class
> [org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy]:
> Could not load requested class :
> org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy ->
> [Help 1]
>
> I tried adding
>
> <dependency>
> <groupId>org.springframework.boot</groupId>
> <artifactId>spring-boot</artifactId>
> <version>${spring.boot.version}</version>
> </dependency>
>
> I also tried adding the dependency several other places, but I think it
> should be a plugin dependency.
>
> I have verified that
> org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy is
> in the org.springframework.boot:spring-boot jar file
>
> And when running maven with -X i get the following:
>
> [DEBUG] Populating class realm plugin>org.jooq:jooq-codegen-maven:3.12.1
> [DEBUG]   Included: org.jooq:jooq-codegen-maven:jar:3.12.1
> [DEBUG]   Included: org.springframework.boot:spring-boot:jar:2.1.8.RELEASE
> (others removed for brevity)
>
> I'm testing with jooq 3.12.1, spring boot 2.1.8.RELEASE
>
> I have not been able to get it working, can anyone give me a hint or point
> me to a working example.
>
> Best regards Jens
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jooq-user+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jooq-user/ffef98dc-c1df-4191-9397-6825c63c54cc%40googlegroups.com
> <https://groups.google.com/d/msgid/jooq-user/ffef98dc-c1df-4191-9397-6825c63c54cc%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jooq-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/CAB4ELO7APYfpuUguxah5jTU7YQPxoWZLE%3D_xLVg4qkdz_h77AQ%40mail.gmail.com.

Reply via email to