Reputation: 472
I have some query string:
String queryStr = "SELECT * FROM car";
I want cast this object to SelectQuery and then use incremental query building.
How to cast String object into SelectQuery?
Upvotes: 1
Views: 960
Reputation: 220762
You cannot cast a String
to any Java object. You can either:
With jOOQ's DSL API, you'd be writing something like:
DSL.using(configuration)
.select()
.from(CAR);
With jOOQ's Model API (i.e. to produce a SelectQuery
), you'd be writing something like:
SelectQuery select = DSL.using(configuration).selectQuery();
select.addFrom(CAR);
You're looking for the latter. The two APIs are compared here, in the manual
This is not what you're looking for, but for completeness's sake, you can also embed SQL strings directly into jOOQ objects, e.g.
ResultQuery<?> query = DSL.using(configuration).resultQuery("SELECT * FROM car");
Upvotes: 2