/** * Constructor for join FROM clauses that join two tables using their * relationship. The primary table of the relationship will be the left side * of the join and the foreign table of the relationship will be the right * side of the join. * * @param join * the join type to use * @param relationship * the relationship to use for joining the tables */ public FromItem(JoinType join, Relationship relationship) { _join = join; _leftSide = new FromItem(relationship.getPrimaryTable()); List<Column> columns = relationship.getPrimaryColumns(); _leftOn = new SelectItem[columns.size()]; for (int i = 0; i < columns.size(); i++) { _leftOn[i] = new SelectItem(columns.get(i)); } _rightSide = new FromItem(relationship.getForeignTable()); columns = relationship.getForeignColumns(); _rightOn = new SelectItem[columns.size()]; for (int i = 0; i < columns.size(); i++) { _rightOn[i] = new SelectItem(columns.get(i)); } }
/** * Constructor for join FROM clauses that join two tables using their * relationship. The primary table of the relationship will be the left side * of the join and the foreign table of the relationship will be the right * side of the join. * * @param join * the join type to use * @param relationship * the relationship to use for joining the tables */ public FromItem(JoinType join, Relationship relationship) { _join = join; _leftSide = new FromItem(relationship.getPrimaryTable()); List<Column> columns = relationship.getPrimaryColumns(); _leftOn = new SelectItem[columns.size()]; for (int i = 0; i < columns.size(); i++) { _leftOn[i] = new SelectItem(columns.get(i)); } _rightSide = new FromItem(relationship.getForeignTable()); columns = relationship.getForeignColumns(); _rightOn = new SelectItem[columns.size()]; for (int i = 0; i < columns.size(); i++) { _rightOn[i] = new SelectItem(columns.get(i)); } }
List<Column> primaryColumns = r.getPrimaryColumns(); List<Column> foreignColumns = r.getForeignColumns(); Table pTable = r.getPrimaryTable();
List<Column> primaryColumns = r.getPrimaryColumns(); List<Column> foreignColumns = r.getForeignColumns(); Table pTable = r.getPrimaryTable();
public static void create(Relationship origRelationship, ImmutableSchema schema) { ImmutableTable primaryTable = getSimilarTable( origRelationship.getPrimaryTable(), schema); assert primaryTable != null; List<Column> primaryColumns = getSimilarColumns( origRelationship.getPrimaryColumns(), primaryTable); checkSameTable(primaryColumns); ImmutableTable foreignTable = getSimilarTable( origRelationship.getForeignTable(), schema); assert foreignTable != null; List<Column> foreignColumns = getSimilarColumns( origRelationship.getForeignColumns(), foreignTable); checkSameTable(foreignColumns); ImmutableRelationship relationship = new ImmutableRelationship( primaryColumns, foreignColumns); primaryTable.addRelationship(relationship); foreignTable.addRelationship(relationship); }
public static void create(Relationship origRelationship, ImmutableSchema schema) { ImmutableTable primaryTable = getSimilarTable( origRelationship.getPrimaryTable(), schema); assert primaryTable != null; List<Column> primaryColumns = getSimilarColumns( origRelationship.getPrimaryColumns(), primaryTable); checkSameTable(primaryColumns); ImmutableTable foreignTable = getSimilarTable( origRelationship.getForeignTable(), schema); assert foreignTable != null; List<Column> foreignColumns = getSimilarColumns( origRelationship.getForeignColumns(), foreignTable); checkSameTable(foreignColumns); ImmutableRelationship relationship = new ImmutableRelationship( primaryColumns, foreignColumns); primaryTable.addRelationship(relationship); foreignTable.addRelationship(relationship); }