HN user

lukaseder

1,269 karma

Java and databases are my professional passion. When they work together, great software can evolve. Many proprietary and standard ideas have been around to make them work together. I feel that there is yet one missing piece gluing them together more intuitively. That's why I created jOOQ:

jOOQ effectively combines complex SQL, typesafety, source code generation, active records, stored procedures, advanced data types, and Java in a fluent, intuitive DSL.

Posts213
Comments244
View on HN
www.jooq.org 2y ago

Transpile any SQL dialect to any SQL dialect (not just to PostgreSQL)

lukaseder
3pts0
testcontainers.com 3y ago

Working with JOOQ and Flyway Using Testcontainers

lukaseder
1pts0
blog.jooq.org 3y ago

How to plot an ASCII bar chart with SQL

lukaseder
1pts0
blog.jooq.org 4y ago

Various meanings of SQL’s PARTITION BY syntax

lukaseder
1pts0
blog.jooq.org 4y ago

Use SQL multiset predicates to compare data sets

lukaseder
2pts0
blog.jooq.org 4y ago

Fun with PostGIS: Mandelbrot set, game of life, and more

lukaseder
28pts0
blog.lettucework.io 4y ago

What my Stackoverflow addiction did to my career

lukaseder
4pts0
blog.jooq.org 4y ago

PostgreSQL 14's enable_memoize for improved performance of nested loop joins

lukaseder
14pts0
blog.jooq.org 4y ago

Write C-style local static variables in Java 16

lukaseder
1pts0
blog.jooq.org 4y ago

Standard SQL/JSON – the sobering parts

lukaseder
1pts0
blog.jooq.org 5y ago

Reactive SQL with JOOQ 3.15 and R2DBC

lukaseder
1pts0
blog.jooq.org 5y ago

JOOQ 3.15’s New Multiset Operator Will Change How You Think About SQL

lukaseder
2pts0
benjiweber.co.uk 5y ago

Thinking in Questions with SQL

lukaseder
4pts0
blog.dbi-services.com 6y ago

The myth of NoSQL (vs. RDBMS) agility

lukaseder
15pts2
www.cockroachlabs.com 6y ago

Build a Java App with CockroachDB and JOOQ

lukaseder
2pts0
www.marcobehler.com 6y ago

Java Database Access: An Overview Guide

lukaseder
2pts0
blog.jooq.org 8y ago

PostgreSQL 11 support for SQL standard GROUPS and EXCLUDE window function clause

lukaseder
2pts0
internet-regulation.org 8y ago

The informational ecosystem of net neutrality

lukaseder
1pts0
blog.jooq.org 8y ago

Finding all palindromes contained in strings with SQL

lukaseder
1pts0
manuel.bernhardt.io 9y ago

Avoiding burnout or lessons learned from six years as an independent consultant

lukaseder
1pts0
www.prohuddle.com 9y ago

Prohuddle: database related webinars (slight bias towards Oracle)

lukaseder
2pts0
blog.jooq.org 9y ago

Creating tables dum and dee in PostgreSQL

lukaseder
2pts0
modern-sql.com 9y ago

The performance impact of SQL WITH clause on all major relational databases

lukaseder
3pts0
vladmihalcea.com 9y ago

A guide to the Phantom Read anomaly, and how it differs between 2PL and MVCC

lukaseder
2pts0
blog.jooq.org 9y ago

A comprehensive guide to the many different ways to JOIN tables in SQL

lukaseder
4pts0
www.percona.com 9y ago

Millions of queries per second: PostgreSQL and MySQL with demanding workloads

lukaseder
3pts0
blog.jooq.org 9y ago

A beginner’s guide to the true order of SQL operations

lukaseder
1pts0
blog.jooq.org 9y ago

Applying queueing theory to dynamic connection pool sizing with FlexyPool

lukaseder
1pts0
articles.microservices.com 9y ago

Microservices: the accidental architecture

lukaseder
5pts1
blog.jooq.org 9y ago

Why you should design your database to optimise for statistics

lukaseder
4pts0

Informix also supports MULTISET natively. Many others support ARRAY, which is equivalent for all practical purposes. jOOQ popularised MULTISET over ARRAY because the existing ARRAY support was less user friendly, mapping results to actual Java array types.

ISO/IEC 9075-2:2023(E) 10.9 <aggregate function>:

<array aggregate function> ::= ARRAY_AGG <left paren> <value expression> [ ORDER BY <sort specification list> ] <right paren>

I hope this helps

Not sure what you mean. I meant that without declaration site variance, ("pragmatic") unsafe casting is everywhere in jOOQ's internals. Without being able to capture wildcards in local type variables, ("pragmatic") rawtypes are everywhere as well (check Collections.swap() for an illustration)

I don't know if your various flatMap / etc methods are purely implemented in the client (it would be quite bad from a performance perspective? But since you're implementing reducers in kotlin, I guess that's what this is), or if you somehow translate the AST to SQL (similar to jinq.org in Java or Slick in Scala or LINQ in .NET).

But in either case, I think that mimicking "idiomatic" client APIs is more of a distraction than something useful. I've explored this here, where I was asked about my opinion on Kotlin's Exposed: https://www.youtube.com/watch?v=6Ji9yKnZ3D8

Obviously, this is ultimately a matter of taste, but just like all these "better SQL languages" (e.g. PRQL) come and go, these translations to "better APIs" also come and go. SQL is the only thing to stay (has been for more than 50 years now!)

We could add parallelism with a .parallelStream() in the right spot easily enough

You typically don't even need to hint it, the optimiser might choose to parallelise on its own, or not, depending on production load... Anyway, that's an overrated topic, IMO.

I think you probably overestimate how easy SQL is because you're an expert in it.

I'm happy when coding in any language / paradigm. When working with XML, I will happily use XSLT, XPath, etc. When working with JSON, I don't mind going into JavaScript. I'm just trying to stay curious.

I really don't think that SQL is "harder" than any other language. It may just be something certain people don't really like, for various reasons.

Your whole product is built on the fact that SQL isn't good enough

I think you're projecting your own distaste into my work here. I love SQL. SQL is wonderful. It's quirky, yes, but what isn't. jOOQ users just don't like working with an external DSL within Java (though many are very happy to write views and stored procedures with SQL and procedural extensions). There's no need for a false dichotomy here. I've worked on large systems that were mostly implemented with SQL written in views, and it was perfect!

Also, jOOQ is much more than just the DSL. SQL transformation, parsing, etc., it's a vast product. The string-y SQL folks could use it as a template engine, without touching the DSL, and still profit from parsing / transformations / mapping: https://blog.jooq.org/using-java-13-text-blocks-for-plain-sq...

Some customers use jOOQ merely to migrate off Oracle to PostgreSQL (via the translating JDBC proxy).

And I'm looking forward to the OpenJDK's Project Babylon. Perhaps we'll get actual macros in Java, soon, which could work well with jOOQ.

Anyway, I didn't mean to hi-jack too much. It's great when people try out new / different approaches. I'm just triggered whenever someone claims that SQL is harder than anything else, when they should have said, they prefer other things and don't want to learn more SQL (which is fine, but quite a different statement).

Regarding 4) among the pros, jOOQ does this (opt in): https://www.jooq.org/doc/dev/manual/sql-building/queryparts/....

It's being done at runtime, thus probably not to be done in production, but during your integration tests as part of the diagnostics feature set: https://www.jooq.org/doc/dev/manual/sql-building/dsl-context...

Regarding 2) among the cons: The recommended approach is to use testcontainers: https://blog.jooq.org/using-testcontainers-to-generate-jooq-...

Reverse engineering a SQL script is also possible, though limiting in terms of what syntax is available in DDL: https://www.jooq.org/doc/dev/manual/code-generation/codegen-...

If your cons are too much to handle, then you can still revert to using native SQL and profit from 1) and 4) by using jOOQ's parser: https://www.jooq.org/doc/dev/manual/sql-execution/parsing-co...

Escape hatches are simple, too: https://www.jooq.org/doc/dev/manual/sql-building/plain-sql-t...

SQL is powerful. A DSL that "fixes" things in this area getting all the other language feature interactions right isn't trivial, all the while users have to learn yet another language. Take PRQL for example: https://prql-lang.org. It looks nice, but the examples are very basic. What about window functions, grouping sets, lateral, DML, recursive SQL, pattern matching, pivot/unpivot etc. Might be doable, but perhaps, they've already made a decision that won't enable one of those features without adding new kludges.

Besides, every single "fix" will be a proprietary solution, while SQL is an ISO/IEC standard that's here to stay and universally adopted.

A good DSL can do much better.

Stonebraker's QUEL was "better", before SQL, and yet, where is QUEL today?

There are tradeoffs everywhere though, so with Jooq you still aren't 1-to-1 with raw SQL

You're probably hinting at writing derived tables / CTEs? jOOQ will never keep you from writing views and table valued functions, though. It encourages you do so! Those objects play very well with code generation, and you can keep jOOQ for the dynamic parts, views/functions for the static parts.

Parsing SQL 4 years ago

It's probably not advertised enough, but jOOQ also contains a parser that can translate between dialects, and let users work with the expression tree to achieve custom SQL translations. A demo here: https://www.jooq.org/translate

Your "parameterized" queries are still serialized strings. Many language bindings for SQL interfaces don't have good support for serializing data types, so you will often see things like ?::datetime in the template string.

How else would you do it, short of a binary query format?

Like any toString() implementation, it is meant for debugging. If the object you're calling toString() on is "attachable" (e.g. a Query), then you get the vendor specific string for additional convenience. If you just call substring(a, b, c).toString(), you'll get a generic rendering.

If you always want the vendor specific SQL string, use DSLContext.render(QueryPart)