2

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!

mellocello
  • 151
  • 1
  • 7
  • 1
    I'm not sure how building SQL queries (including window functions) relates to HQL, but if you're really just looking for a SQL builder, there have been other questions on Stack Overflow already: http://stackoverflow.com/questions/5620985/is-there-any-good-dynamic-sql-builder-library-in-java, http://stackoverflow.com/questions/370818/cleanest-way-to-build-an-sql-string-in-java, http://stackoverflow.com/questions/22802323/runtime-sql-query-builder. Why did you mention HQL? – Lukas Eder Aug 11 '15 at 08:13
  • HQL because that's the variant of SQL I'm using. – mellocello Aug 12 '15 at 14:19

1 Answers1

0

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.

Community
  • 1
  • 1
mellocello
  • 151
  • 1
  • 7
  • Looking closer at the JOOQ documentation, it doesn't support Hive. I need to look at QueryDSL to see if it supports my use case. I don't believe it does since it seems to rely on codegen... – mellocello Aug 13 '15 at 13:40
  • Can you mark your own answer as correct to indicate that the problem is solved? – Simon Aug 24 '15 at 17:16