/** * Internal method for generating from clause. This method should be called * after generating other clauses because it relies on the aliases they * create. This method takes every path that is called for in the other * clauses and makes it available as an alias using left joins. It also adds * join fetching for properties specified by <code>fetches</code> if * <code>doEagerFetching</code> is <code>true</code>. <b>NOTE:</b> When * using eager fetching, <code>applyFetches()</code> must be executed first. */ protected String generateFromClause(SearchContext ctx, boolean doEagerFetching) { StringBuilder sb = new StringBuilder(" from "); sb.append(getMetadataUtil().get(ctx.rootClass).getEntityName()); sb.append(" "); sb.append(ctx.getRootAlias()); sb.append(generateJoins(ctx, doEagerFetching)); return sb.toString(); }
sb.append(getPathRef(ctx, property)); sb.append(" "); sb.append(ctx2.getRootAlias()); sb.append(joins); sb.append(where);
String prop = fields.get(0).getProperty(); if (prop == null || "".equals(prop)) { sb.append(ctx.getRootAlias()); } else { sb.append(getPathRef(ctx, prop));
prop = ctx.getRootAlias(); } else { AliasNode aliasNodeForProperty = getAliasForPathIfItExists(ctx, field.getProperty()); return "select distinct " + ctx.getRootAlias(); else return "select " + ctx.getRootAlias();
/** * Given a full path to a property (ex. department.manager.salary), return * the reference to that property that uses the appropriate alias (ex. * a4_manager.salary). */ protected String getPathRef(SearchContext ctx, String path) { if (path == null || "".equals(path)) { return ctx.getRootAlias(); } String[] parts = splitPath(ctx, path); return getOrCreateAlias(ctx, parts[0], false).alias + "." + parts[1]; }