}
orderByBuilder.end();
}
// Try building this query, because we need to check the # of columns selected and the # of sources ...
Query query = (Query)builder.query();
if (query.columns().isEmpty() && query.source() instanceof AllNodes) {
// This is basically 'SELECT * FROM __ALLNODES__", which means that no type was explicitly specified and
// nothing was selected from that type. According to JCR 1.0 Section 6.6.3.1, this equates to
// 'SELECT * FROM [nt:base]', and since there is just one property on nt:base (but many on __ALLNODES__)
// this really equates to 'SELECT [jcr:primaryType] FROM __ALLNODES__'.
builder.select("jcr:primaryType");