Digest for jooq-user@googlegroups.com - 5 updates in 2 topics

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Digest for jooq-user@googlegroups.com - 5 updates in 2 topics

http://groups.google.com/group/jooq-user/topics mailing list
"Jens Teglhus Møller" <[hidden email]>: Sep 17 01:57AM -0700

I'm trying to get schema generation using JPADatabase to work with spring
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:
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
as strategy [org.hibernate.boot.model.naming.PhysicalNamingStrategy]:
Unable to load class
Could not load requested class :
org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy ->
[Help 1]
I tried adding
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
Lukas Eder <[hidden email]>: Sep 17 02:30PM +0200

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:
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
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 @@
+ <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>
<!-- 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 @@
+ <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>
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:
I hope this helps,
On Tue, Sep 17, 2019 at 10:57 AM Jens Teglhus Møller <[hidden email]>
"Jens Teglhus Møller" <[hidden email]>: Sep 17 02:35AM -0700

I'm trying to do some kind of rapid schema evolution where I use JPA for
schema development.
I develop/test on H2 but will end up on mysql or perhaps postgres.
It would be nice if the H2 database instantiated by the JPADatabase
generator could be controlled so you could put H2 into compat mode <
I checked the source
and currently the jdbc url is hardcoded as:
connection = new
org.h2.Driver().connect("jdbc:h2:mem:jooq-meta-extensions-" +
UUID.randomUUID(), info);
So either you could overide first argument to connect completely with a
property or a property that is appended (so you can give a value like:
Does it make sense? I can probably create a PR for this but would like to
know which approach you would prefer.
Best regards Jens
Lukas Eder <[hidden email]>: Sep 17 01:25PM +0200

Hi Jens,
Thank you very much for your message.
Exposing H2 specific flags has been a recurring request in the past for
both the DDLDatabase and the JPADatabase, and we've rejected it based on
the fact that we do not really want to document / guarantee / or specify
any dependency on H2 in DDLDatabase or JPADatabase. The fact that we're
using H2 behind the scenes is an implementation detail that has brought us
quick wins - i.e. being able to do this kind of generation *at all* at the
cost of certain incompatibilities this may cause. The current
implementation is likely going to be replaced soon (hopefully 3.13) as
we're working on DDL simulator that mainly benefits the DDLDatabase, but
will also help improve some JPADatabase edge cases. See:
Note we've relaxed our stance on this a little bit by forwarding any
JPADatabase configuration properties starting with "hibernate." or "javax."
to Hibernate's MetadataSources settings. It is unlikely that we're going to
replace the Hibernate dependency in DDLDatabase any time soon, so this is
slightly different. As such, it might be possible to work around the
current limitations by passing a naming strategy to Hibernate, which might
yield even better results than using H2's flags:
Alternatively, JPADatabase is just a few lines of code - you could fork it
and maintain your own version that handles this, for now, until we solve
this problem more thoroughly using the DDL simulation approach.
I hope this helps,
On Tue, Sep 17, 2019 at 11:35 AM Jens Teglhus Møller <[hidden email]>
Lukas Eder <[hidden email]>: Sep 17 04:59AM -0700

I just realised, you already explored the naming strategy option in your
other discussion:
Will reply there right away.
On Tuesday, September 17, 2019 at 1:25:21 PM UTC+2, Lukas Eder wrote:
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to [hidden email].