Digest for jooq-user@googlegroups.com - 5 updates in 3 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 3 topics

http://groups.google.com/group/jooq-user/topics mailing list
[hidden email]: Oct 03 05:05AM -0700

Here's my workflow:
- I have a folder of db migration scripts
- Flyway runs them all on an h2 database in Postgres mode, then dumps the
final schema
- There's a gradle task that makes sure that the db migrations -> schema
mapping is always up-to-date
- I'd like to slurp this schema into an h2 in Postgres mode, and use that
to generate code with jOOQ.
The problem is, jOOQ barfs when generating code against the h2 db in
Postgres mode. Here's the jOOQ config:
jooq {
version = '3.9.5'
edition = 'OSS'
models(sourceSets.main) {
generator {
name = 'org.jooq.util.DefaultGenerator'
database {
driver = 'org.h2.Driver'
url = 'jdbc:h2:mem:;MODE=PostgreSQL;INIT=runscript from
schema = 'public'
strategy {
name = 'org.jooq.util.DefaultGeneratorStrategy'
database {
name = 'org.jooq.util.postgres.PostgresDatabase'
inputSchema = 'public'
generate {
immutablePojos = true
daos = true
target {
packageName = 'models.db.gen'
directory = 'src/main/jooq-generated'
And here's the error output:
04:55:47.446 [main] DEBUG org.jooq.tools.LoggerListener - Executing query
: select 1 as "one"
04:55:47.473 [main] DEBUG org.jooq.tools.StopWatch - Query executed
: Total: 34.105ms
04:55:47.605 [main] DEBUG org.jooq.tools.LoggerListener - Fetched result
: +----+
04:55:47.605 [main] DEBUG org.jooq.tools.LoggerListener -
: | one|
04:55:47.605 [main] DEBUG org.jooq.tools.LoggerListener -
: +----+
04:55:47.605 [main] DEBUG org.jooq.tools.LoggerListener -
: | 1|
04:55:47.605 [main] DEBUG org.jooq.tools.LoggerListener -
: +----+
04:55:47.606 [main] DEBUG org.jooq.tools.StopWatch - Finishing
: Total: 169.54ms, +135.435ms
04:55:47.606 [main] DEBUG org.jooq.tools.LoggerListener - Executing query
: select "pg_catalog"."pg_namespace"."nspname" from
04:55:47.608 [main] WARN org.jooq.util.AbstractDatabase - SQL exception
: Exception while executing meta query: Schema "pg_catalog" not
found; SQL statement:
select "pg_catalog"."pg_namespace"."nspname" from
"pg_catalog"."pg_namespace" [90079-196]
Any guesses for how I can trick jOOQ into generating PostgreSQL-style code
from an h2 db in Postgres mode?
Paul Hamer <[hidden email]>: Oct 03 02:16AM -0700

I'm using the following construct:
int count = dsl.insertInto(...)
My question is, what will "count" contain? The number of added rows, or the
number of updated rows? Or perhaps the sum of both? I can't seem to find it
in the documentation.
Kind regards,
Paul Hamer <[hidden email]>: Oct 03 02:20AM -0700

LOL, I just read the execute() javadoc again and found:
*Merge* : the result may have no meaning
Guess that answers my question ;-)
I missed it before, because I did not trigger on "merge".
On Tuesday, October 3, 2017 at 11:16:50 AM UTC+2, Paul Hamer wrote:
[hidden email]: Oct 02 10:59AM -0700

To fetch a query as custom type using RecordMapper, an intermediary Record
object has to be created and discarded for each row:
ResultSet row -> Record -> mapped to custom type
This adds unnecessary overhead.
Is there a way to map the JDBC ResultSet directly?
fetchResultSet works but I'm looking for something that fits into JOOQ's
(excellent) fluent API.
Something like
List<T> fetch(ResultSetMapper<T>)
Where ResultSetMapper<T> has a single method and can be registered like
T map(ResultSet, Field[] fields) throws SQLException;
Lukas Eder <[hidden email]>: Oct 03 08:58AM +0200

Thank you very much for your suggestion. Indeed, the overhead of creating
an intermediary Record should be avoided. The main reason why it currently
cannot is because of the RecordListener SPI semantics, which guarantees
that any Record ever fetched by jOOQ passes through this SPI. The
fetchResultSet() method that you're mentioning is breaking this assumption.
There's a pending issue for jOOQ 3.11, which will address this
The new default behaviour will be to bypass intermediary Record types if no
RecordListeners are registered in the Configuration. There are quite a few
API methods that can then be optimised for most users.
Right now, I'm afraid you have to resort to writing your own utility to get
the ResultSetMapper semantics.
I hope this helps,
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].