Feature request: Allow setting H2 compat mode in JPADatabase

8 views
Skip to first unread message

Jens Teglhus Møller

unread,
Sep 17, 2019, 5:35:28 AM9/17/19
to jOOQ User Group
Hi

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 <http://www.h2database.com/html/features.html#compatibility>.


                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: ;MODE=MySQL;DATABASE_TO_LOWER=TRUE).

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

unread,
Sep 17, 2019, 7:25:21 AM9/17/19
to jOOQ User Group
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: https://github.com/jOOQ/jOOQ/projects/1

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,
Lukas

--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/1790eb64-9f2f-449a-89e2-a7a45d3ebda5%40googlegroups.com.

Lukas Eder

unread,
Sep 17, 2019, 7:59:13 AM9/17/19
to jOOQ User Group
I just realised, you already explored the naming strategy option in your other discussion:

Will reply there right away.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages