You have several options to achieve the same through the jOOQ API. The
simplest way in my opinion is to avoid the SQL [t1] JOIN [t2] ON ...
syntax, and to phrase a query like this instead:
SELECT *
FROM t1, t2, t3
WHERE [join criteria t1 <=> t2]
AND [join criteria t2 <=> t3]
This can be achieved simply:
create.select()
.from(tableList)
.where(combinedJoinCriteria)
.fetch();
Relevant API docs can be found here:
- SelectFromStep.from(Collection<? extends TableLike<?>>:
http://www.jooq.org/javadoc/latest/org/jooq/SelectFromStep.html#from(java.util.Collection)
- SelectWhereStep.where(Collection<Condition>):
http://www.jooq.org/javadoc/latest/org/jooq/SelectWhereStep.html#where(java.util.Collection)
Note, there had been a similar question on Stack Overflow, recently,
regarding the creation of dynamic predicates:
http://stackoverflow.com/q/14051080/521799
I encourage you to play around with jOOQ's API a little bit. Most DSL
methods are overloaded for convenience
Cheers
Lukas
2012/12/31 Gayathri B S <[email protected]>
> Hi,
>
> I want to create dynamic query which join multiple tables.The
> tables to be joined will be in Collections(ArrayList) and i dint know in
> advance.
>
> So While creating query i dint know how much join will be
> there.Depends on the size of ArrayList how can I write query which join all
> the tables.
>
> Thanks in advance.
>
> //For example
>
> myArrayList = {tableA,tableB,tableC}
>
> so my query should be like
>
>
> create.select()
> .from(table1)
> .join(table2)
>
> .join(table3)
>
> .execute();
>
>