In short "No" is the answer but ...
The Query object has a getGeneratedSql() method that returns the actual SQL String executed. If you look at InQueryExpression.prepareExpression() we see:
public void prepareExpression(BeanQueryRequest<?> request) {
CQuery<?> subQuery = compileSubQuery(request);
this.bindParams = subQuery.getPredicates().getWhereExprBindValues();
this.sql = subQuery.getGeneratedSql().replace('\n', ' ');
}
private CQuery<?> compileSubQuery(BeanQueryRequest<?> queryRequest) {
SpiEbeanServer ebeanServer = (SpiEbeanServer) queryRequest.getEbeanServer();
return ebeanServer.compileQuery(subQuery, queryRequest.getTransaction());
}
... so you will see a compileQuery() method on SpiEbeanServer (but not publicly exposed per say).
Ultimately this sounds like ... compile 2 queries, combine the result bind values and sql ... and then execute as RawSql or findNative(). So that is "possible" if you are keen etc but to me it is getting into a "questionable complexity" area.
The question I'd ask first is ...
A) can you create a DB view?
B) why not use RawSql ? ... noting that with RawSql Ebean can dynamically extend a parsed (or column defined) RawSql query with custom predicates and order by etc.
... I'd look at these options first before the compile/merge approach (which could get interesting with named parameters etc).
Cheers, Rob.