Here's the code:
SelectQuery<Record> resultQuery = dslContext.selectQuery();
for(int floor : floors) {
method1(resultQuery,floor);
}
And then:
method1(SelectQuery<Record> resultQuery,int floor){
SelectQuery<Record> query = dslContext.selectQuery();
/*
Now I am creating subqueries for parameter floor by adding condition
in above created query
*/
resultQuery.union(query);
}
Issue is that in final query(resultQuery) I am getting "Select * from dual" appended. It is adding because I created "resultQuery" as empty.
Is there any way I can replace or remove "Select * from dual" from final query.
Thanks
SelectQuery<Record> result = null;
for (int floor : floors) {
result = method1(result, floor);
}
With:
SelectQuery<Record> method1(SelectQuery<Record> result, int floor) {
SelectQuery<Record> query = dslContext.selectQuery();
/* your logic ... */
if (result == null)
return query;
else
return result.union(query);
}
Optional<Select<Record>> result =
floors.stream()
.map(this::method2)
.reduce(Select::union)
With:
Select<Record> method2(int floor) {
SelectQuery<Record> query = dslContext.selectQuery();
/* your logic ... */
return query;
}
See also:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.