String alias = _schemaAlias;
if (isPathInThisContext(pj) || table.isAssociation())
alias = null;
// find the context where this alias is defined
Context ctx = (alias != null) ?
_ctx.findContext(alias) : null;
if (ctx != null)
sel = (SelectImpl) ctx.getSelect();
if (!create)
i = sel.findAlias(table, key); // find in parent and in myself
else
i = sel.getAlias(table, key); // find in myself
if (i != null)
return i;
if (create) { // create here
i = sel.createAlias(table, key);
} else if (ctx != null && ctx != ctx()) { // create in other select
i = ((SelectImpl)ctx.getSelect()).createAlias(table, key);
}
return i;
}