public String assembleJoinClause(String leftName, String rightName, int semantic) { StringBuffer sb = new StringBuffer(); String leftAlias = leftName.substring(0, leftName.indexOf(".")); String rightAlias = rightName.substring(0, rightName.indexOf("."));  String leftCol = leftName.substring(leftName.indexOf(".") + 1); String rightCol = rightName.substring(rightName.indexOf(".") + 1);  NSArray k; EOEntity rightEntity; EOEntity leftEntity;  if (leftAlias.equals("t0")) { leftEntity = entity(); } else { k = aliasesByRelationshipPath().allKeysForObject(leftAlias); String leftKey = k.count()>0? (String)k.lastObject() : ""; leftEntity = entityForKeyPath(leftKey); }  if (rightAlias.equals("t0")) { rightEntity = entity(); } else { k = aliasesByRelationshipPath().allKeysForObject(rightAlias); String rightKey = k.count()>0? (String)k.lastObject() : ""; rightEntity = entityForKeyPath(rightKey); } String rightTable = rightEntity.externalName(); String leftTable = leftEntity.externalName();  JoinClause jc = new JoinClause();  jc.table1 = leftTable + " " + leftAlias;  switch (semantic) { case EORelationship.LeftOuterJoin: jc.op = " LEFT OUTER JOIN "; break; case EORelationship.RightOuterJoin: jc.op = " RIGHT OUTER JOIN "; break; case EORelationship.FullOuterJoin: jc.op = " FULL OUTER JOIN "; break; case EORelationship.InnerJoin: jc.op = " INNER JOIN "; break; }  jc.table2 = rightTable + " " + rightAlias;  if (leftCol.equals(rightCol)) { jc.joinCondition = " USING (" + leftCol + ")"; } else { jc.joinCondition = " ON " + leftName + " = " + rightName; } return jc.toString();
public String assembleJoinClause(String leftName, String rightName, int semantic) { return createJoinClause(leftName, rightName, semantic).toString();
    public String assembleJoinClause(String leftName,                                     String rightName,                                     int semantic) {        StringBuffer sb = new StringBuffer();        String leftAlias = leftName.substring(0, leftName.indexOf("."));        String rightAlias = rightName.substring(0, rightName.indexOf("."));        String leftCol = leftName.substring(leftName.indexOf(".") + 1);        String rightCol = rightName.substring(rightName.indexOf(".") + 1);        NSArray k;        EOEntity rightEntity;        EOEntity leftEntity;        if (leftAlias.equals("t0")) {            leftEntity = entity();        } else {            k = aliasesByRelationshipPath().allKeysForObject(leftAlias);            String leftKey = k.count()>0? (String)k.lastObject() : "";            leftEntity = entityForKeyPath(leftKey);        }        if (rightAlias.equals("t0")) {            rightEntity = entity();        } else {            k = aliasesByRelationshipPath().allKeysForObject(rightAlias);            String rightKey = k.count()>0? (String)k.lastObject() : "";            rightEntity = entityForKeyPath(rightKey);        }        String rightTable = rightEntity.externalName();        String leftTable = leftEntity.externalName();        JoinClause jc = new JoinClause();        jc.table1 = leftTable + " " + leftAlias;        switch (semantic) {            case EORelationship.LeftOuterJoin:                jc.op = " LEFT OUTER JOIN ";                break;            case EORelationship.RightOuterJoin:                jc.op = " RIGHT OUTER JOIN ";                break;            case EORelationship.FullOuterJoin:                jc.op = " FULL OUTER JOIN ";                break;            case EORelationship.InnerJoin:                jc.op = " INNER JOIN ";                break;        }        jc.table2 = rightTable + " " + rightAlias;        if (leftCol.equals(rightCol)) {            jc.joinCondition = " USING (" + leftCol + ")";        } else {            jc.joinCondition = " ON " + leftName + " = " + rightName;        }        return jc.toString();    }