Looking at their online-translation demo it looks to me as though jOOQ is capable of transpiling queries between different DB engines. We have a large ecosystem of services depending on MSSQL (that would be very hard to migrate in one go) and I would like to run an experiment whether it's possible to replace MSSQL with Postgres + jOOQ.
Question:
What would be a minimal programmatic translation example, starting with a T-SQL query String and ending up with pgSQL query String? I have a hard time finding documentation on this.
As of jOOQ 3.11 (currently published) and 3.12 (due for early Q3 2019), the translator will not be entirely ready for a fully automated translation between dialects. It can translate a large amount of simple SQL but we're still working on a large backlogs of edge cases. Your feedback would be very valuable: https://github.com/jOOQ/jOOQ/issues/new
Regarding your specific questions:
1) Are there any example projects out there that I could have a look, which use jOOQ as purely a translational tool rather than having it define the schema?
Probably not yet, as this product is not production ready yet
2) If not, what would be a minimal example, starting with a T-SQL query String and ending up with pgSQL query String? I have a hard time finding documentation on this.
Currently, our recommendation is to translate your T-SQL queries to jOOQ API usage. You can continue working with SQL Server until you're finished migrating your queries, and then "just" switch to PostgreSQL. A lot of users have applied this approach very successfully. The benefit is you can profit from jOOQ's query building capabilities right away for your dynamic SQL.
If you would like to work with the experimental translation support, you could use the DSLContext.parsingConnection()
or DSLContext.parsingDataSource()
, which act as a proxy to your "real" JDBC driver. Again, at the current stage, this is experimental and not production ready for automated migrations.
However, using the website, or the backing APIs (e.g. ParserCLI
), you can semi-automate this migration, and I'm positive, the translation will work for 60%+ of your queries already.