@Override public final void addFrom(Collection<? extends TableLike<?>> f) { for (TableLike<?> provider : f) from.add(provider.asTable()); }
@Override public final void addJoinOnKey(TableLike<?> table, JoinType type, ForeignKey<?, ?> key) { // TODO: This and similar methods should be refactored, patterns extracted... int index = getFrom().size() - 1; Table<?> joined = null; switch (type) { case JOIN: case LEFT_OUTER_JOIN: case RIGHT_OUTER_JOIN: case FULL_OUTER_JOIN: case LEFT_SEMI_JOIN: case LEFT_ANTI_JOIN: joined = getFrom().get(index).join(table, type).onKey(key); break; default: throw new IllegalArgumentException("JoinType " + type + " is not supported with the addJoinOnKey() method. Use INNER or OUTER JOINs only"); } getFrom().set(index, joined); }
SelectQueryImpl(Configuration configuration, TableLike<? extends R> from, boolean distinct) { super(configuration); this.distinct = distinct; this.select = new SelectFieldList(); this.from = new TableList(); this.condition = new ConditionProviderImpl(); this.connectBy = new ConditionProviderImpl(); this.connectByStartWith = new ConditionProviderImpl(); this.groupBy = new QueryPartList<GroupField>(); this.having = new ConditionProviderImpl(); this.window = new WindowList(); this.orderBy = new SortFieldList(); this.seek = new QueryPartList<Field<?>>(); this.limit = new Limit(); if (from != null) { this.from.add(from.asTable()); } this.forUpdateOf = new QueryPartList<Field<?>>(); this.forUpdateOfTables = new TableList(); }
RowsFrom(Table<?>... tables) { super("rows from"); this.tables = new TableList(Arrays.asList(tables)); }
@SuppressWarnings("unchecked") @Override public final Class<? extends R> getRecordType() { // Generated record classes only come into play, when the select is // - on a single table // - a select * if (getFrom().size() == 1 && getSelect0().isEmpty()) { return (Class<? extends R>) getFrom().get(0).asTable().getRecordType(); } else { return (Class<? extends R>) RecordImpl.class; } }
private final <Q extends QueryPartList<? super Field<?>>> Q resolveAsterisk(Q result) { // [#109] [#489] [#7231]: SELECT * is only applied when at least one // table from the table source is "unknown", i.e. not generated from a // physical table. Otherwise, the fields are selected explicitly if (knownTableSource()) for (TableLike<?> table : getFrom()) for (Field<?> field : table.asTable().fields()) result.add(field); // The default is SELECT 1, when projections and table sources are // both empty if (getFrom().isEmpty()) result.add(one()); return result; }
Utils.fieldNames(context, forUpdateOf); else if (!forUpdateOfTables.isEmpty()) { context.sql(" ").keyword("of").sql(" "); forUpdateOfTables.toSQLFieldNames(context); break;
@Override public final void setForShare(boolean forShare) { this.forUpdate = false; this.forShare = forShare; this.forUpdateOf.clear(); this.forUpdateOfTables.clear(); this.forUpdateMode = null; this.forUpdateWait = 0; }
SelectQueryImpl(Configuration configuration, WithImpl with, TableLike<? extends R> from, boolean distinct) { super(configuration); this.with = with; this.distinct = distinct; this.select = new SelectFieldList<SelectFieldOrAsterisk>(); this.from = new TableList(); this.condition = new ConditionProviderImpl(); this.connectBy = new ConditionProviderImpl(); this.connectByStartWith = new ConditionProviderImpl(); this.having = new ConditionProviderImpl(); this.orderBy = new SortFieldList(); this.seek = new QueryPartList<Field<?>>(); this.limit = new Limit(); this.unionOp = new ArrayList<CombineOperator>(); this.union = new ArrayList<QueryPartList<Select<?>>>(); this.unionOrderBy = new SortFieldList(); this.unionSeek = new QueryPartList<Field<?>>(); this.unionLimit = new Limit(); if (from != null) this.from.add(from.asTable()); }
this.start = function() { this.tableList = new TableList(); this.listView = new ListView({collection: this.tableList}); this.tableList.reset(initialModels); };
@SuppressWarnings("unchecked") @Override public final Class<? extends R> getRecordType() { // Generated record classes only come into play, when the select is // - on a single table // - a select * if (getFrom().size() == 1 && getSelect0().isEmpty()) { return (Class<? extends R>) getFrom().get(0).asTable().getRecordType(); } else { return (Class<? extends R>) RecordImpl.class; } }
final SelectFieldList getSelect1() { if (getSelect0().isEmpty()) { SelectFieldList result = new SelectFieldList(); // [#109] [#489]: SELECT * is only applied when at least one table // from the table source is "unknown", i.e. not generated from a // physical table. Otherwise, the fields are selected explicitly if (knownTableSource()) { for (TableLike<?> table : getFrom()) { for (Field<?> field : table.asTable().fields()) { result.add(field); } } } // The default is SELECT 1, when projections and table sources are // both empty if (getFrom().isEmpty()) { result.add(one()); } return result; } return getSelect0(); }
@Override public final void setForUpdateOf(Collection<? extends Field<?>> fields) { setForUpdate(true); forUpdateOf.clear(); forUpdateOfTables.clear(); forUpdateOf.addAll(fields); }
@Override public final void addJoinOnKey(TableLike<?> table, JoinType type) throws DataAccessException { // TODO: This and similar methods should be refactored, patterns extracted... int index = getFrom().size() - 1; Table<?> joined = null; switch (type) { case JOIN: case LEFT_OUTER_JOIN: case RIGHT_OUTER_JOIN: case FULL_OUTER_JOIN: case LEFT_SEMI_JOIN: case LEFT_ANTI_JOIN: joined = getFrom().get(index).join(table, type).onKey(); break; default: throw new IllegalArgumentException("JoinType " + type + " is not supported with the addJoinOnKey() method. Use INNER or OUTER JOINs only"); } getFrom().set(index, joined); }
@Override public final void setForUpdateOf(Table<?>... tables) { setForUpdate(true); forUpdateOf = null; forUpdateOfTables = new TableList(Arrays.asList(tables)); }
@Override public final void addFrom(Collection<? extends TableLike<?>> f) { for (TableLike<?> provider : f) { from.add(provider.asTable()); } }
boolean hasFrom = !getFrom().isEmpty()
@Override public final void addJoinOnKey(TableLike<?> table, JoinType type, TableField<?, ?>... keyFields) throws DataAccessException { // TODO: This and similar methods should be refactored, patterns extracted... int index = getFrom().size() - 1; Table<?> joined = null; switch (type) { case JOIN: case LEFT_OUTER_JOIN: case RIGHT_OUTER_JOIN: case FULL_OUTER_JOIN: case LEFT_SEMI_JOIN: case LEFT_ANTI_JOIN: joined = getFrom().get(index).join(table, type).onKey(keyFields); break; default: throw new IllegalArgumentException("JoinType " + type + " is not supported with the addJoinOnKey() method. Use INNER or OUTER JOINs only"); } getFrom().set(index, joined); }