List<DbRelationship> dbRelationships = relationship.getDbRelationships();
// reverse order to get the nearest to the correlated of the direct
// relation
for (int i = dbRelationships.size() - 1; i > 0; i--) {
DbRelationship dbRelationship = dbRelationships.get(i);
String subqueryTargetTableName = quoter.quotedFullyQualifiedName((DbEntity) dbRelationship
.getTargetEntity());
String subqueryTargetAlias;
if (i == dbRelationships.size() - 1) {
subqueryTargetAlias = subqueryRootAlias;
context.append(subqueryTargetTableName).append(' ').append(subqueryTargetAlias);