Search code examples
javasqlhqlquerydsl

Query DSL-like mechanism in Java for runtime sql binding


I'm looking for a Java library that provides Query DSL-like functionality against HQL, but only for runtime SQL bindings. In particular, I just need a SQL generator so that I don't have to model joins, window clauses, etc..., etc...

The schema that we need to query against is only available at runtime, so we can't build an ORM against it.

So for example, I want to be able to write:

int count = from("Account").count();

instead of:

string statement = "SELECT COUNT(1) FROM Account";

It would be beneficial if it also supported window clauses.

If there's no such thing out there, I'll just roll my own.

Thanks in advance!


Solution

  • This is a duplicate of this answer: Runtime SQL Query Builder

    I assumed that QueryDSL and JOOQ only relied on schema generation based on the documentation in QueryDSL, but the above answer set me right.

    Thanks Lukas.