Suppose I have a decomposed query in some format, like "fields=a,b,c;
whereClause='1=1'; groupBy=b,c;" etc. Some parts of the query might be
missing, which corresponds to missing SQL part (e.g. a select without where
clause). Having that, I'd like to compose a jOOQ query which could be run
by some external executor, suppose a default DSL.using( conn, dialect
).fetch( constructedQuery ).
Currently my code looks like the following:
Select select = select( fieldsList ).from( myTable );
if( hasWhereClause )
{
select = ((SelectJoinStep) select).where( whereClause );
}
if( hasGroupBy )
{
select = ((SelectConditionStep) select).groupBy( groupByClause );
}
if( hasOrderBy )
{
select = ((SelectHavingStep) select).orderBy( orderByClause );
}
...
return select;
As you see, because of the class hierarchy (which I actually like and
admire a bit, since I can see it could not be easily designed), I either
need multiple class casts or lots of nested if-statements - and both
options are not really exciting.
So maybe I'm missing something, or maybe there's an alternative builder for
jOOQ queries (if not, I suppose one of the best solutions would be to have
one), with which the code would look like the following:
new JooqQueryBuilder()
.withFrom(TableLike)
.withWhereClause(Condition)
.withGroupBy(List<GroupByField>)
...
Hope I managed to clearly describe the problem, but if you need any further
clarification - I would be glad to provide such.
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.