Search code examples
jooq

JOOQ - Is there any similar tool like SQL 2 jOOQ Parser?


Since JOOQ 3.6+, they no longer ship with SQL 2 jOOQ Parser. Search on the internet, I can't find the tool SQL 2 jOOQ Parser anywhere.

Just wonder is there any similar tool like SQL 2 jOOQ Parser so we can generate the JOOQ code from native sql?


Solution

  • There's a feature request for this: https://github.com/jOOQ/jOOQ/issues/6277

    From the feature request:

    This was already implemented in the past by the https://github.com/sqlparser/sql2jooq third party module, but it suffered from several flaws:

    • It didn't produce very good jOOQ code
    • It worked only for MySQL and PostgreSQL
    • It depended on a third party parser (by Gudu Soft), which was proprietary and not under our control
    • It was hard to use

    The product got zero (!) user feedback over quite some time, which is never a good sign.

    Eventually, we'll re-iterate the idea, but it's a lot of work, and there are probably more interesting things that can be done first. The approach most people will choose when writing jOOQ queries is they:

    • Choose a test driven approach where the feedback cycle is tight, such that executing a query to test if it's correct is done relatively easily
    • Use views (seriously, use views! Why don't people use views more often?) for your very complex static SQL and query the views from jOOQ