Query string for Query object or SelectQuery using jOOQ

I have a query string:

String queryStr = "SELECT * FROM car";


I want this object to be selected in a SelectQuery and then use incremental query building.

How can I pass a String object to SelectQuery?


source to share

1 answer

You cannot use String

for any Java object. You can:

Convert SQL string to jOOQ query

With the jOOQ DSL API, you would write something like:



With the jOOQ Model API (i.e. to create SelectQuery

), you should write something like:

SelectQuery select = DSL.using(configuration).selectQuery();


You are looking for the latter. The two APIs are compared here in the manual

Insert SQL string into jOOQ query

This is not what you are looking for, but for completeness, you can also embed SQL strings directly into jOOQ objects, for example.

ResultQuery<?> query = DSL.using(configuration).resultQuery("SELECT * FROM car");




All Articles