public Select newSelect() { return new SelectImpl(_conf); }
public void addJoinClassConditions() { sel.addJoinClassConditions(); }
/** * Calculate total number of aliases. */ private int aliasSize() { return aliasSize(false, null); }
/** * Order on a SQL buffer or string. */ private boolean orderBy(Object sql, boolean asc, Joins joins, boolean sel, boolean aliasOrder) { Object order = sql; if (aliasOrder) { order = toOrderAlias(_orders++); _selects.setSelectAs(sql, (String) order); } if ((_flags & RECORD_ORDERED) != 0) { if (_ordered == null) _ordered = new ArrayList(5); _ordered.add(sql); } getJoins(joins, true); appendOrdering(order, asc); if (sel) { int idx = _selects.indexOfAlias(sql); if (idx == -1) { _selects.setAlias(nullId(), sql, false); return true; } } return false; }
/** * Perform an operation on a column. */ private boolean columnOperation(Column col, boolean sel, Boolean asc, PathJoins pj, boolean aliasOrder) { String as = null; if (asc != null && (aliasOrder || (_flags & RECORD_ORDERED) != 0)) { Object id; if (pj == null || pj.path() == null) id = col; else id = getColumnAlias(col, pj); if ((_flags & RECORD_ORDERED) != 0) { if (_ordered == null) _ordered = new ArrayList(5); _ordered.add(id); } if (aliasOrder) { as = toOrderAlias(_orders++); _selects.setSelectAs(id, as); } } boolean seld = sel && select(col, pj, false); if (asc != null) { String alias = (as != null) ? as : getColumnAlias(col, pj); appendOrdering(alias, asc.booleanValue()); } return seld; }
i = findAliasForQuery(table, pj, key, create); i = findAlias(table, key); i = aliasSize(false, null); recordTableAlias(table, key, i); return i.intValue();
/** * Return the alias for the given table under the given joins. * NOTE: WE RELY ON THESE INDEXES BEING MONOTONICALLY INCREASING FROM 0 */ private int getTableIndex(Table table, PathJoins pj, boolean create) { // if we have a from select, then there are no table aliases if (_from != null) return -1; Object key = table.getFullName(); if (pj != null && pj.path() != null) key = new Key(pj.path().toString(), key); // check out existing aliases Integer i = findAlias(table, key, false, null); if (i != null) return i.intValue(); if (!create) return -1; // not found; create alias i = Numbers.valueOf(aliasSize()); recordTableAlias(table, key, i); return i.intValue(); }
public Joins and(Joins joins1, Joins joins2) { return sel.and(joins1, joins2); }
public void append(SQLBuffer buf, Joins joins) { sel.append(buf, joins); }
public void clearSelects() { sel.clearSelects(); }
public void clearOrdering() { sel.clearOrdering(); }
/** * This method is to provide override for non-JDBC or JDBC-like * implementation of executing eager selects. */ public Result getEagerResult(Connection conn, PreparedStatement stmnt, ResultSet rs, JDBCStore store, JDBCFetchConfiguration fetch, boolean forUpdate, SQLBuffer sql) throws SQLException { SelectResult res = new SelectResult(conn, stmnt, rs, _dict); res.setSelect(this); res.setStore(store); res.setLocking(forUpdate); try { addEagerResults(res, this, store, fetch); } catch (SQLException se) { res.close(); throw se; } return res; }
if (j1Empty || j2Empty) { if (j1Empty && !j2Empty) { collectOuterJoins(j2); if (!j2.isEmpty()) _flags |= IMPLICIT_DISTINCT; } else if (j2Empty && !j1Empty) { collectOuterJoins(j1); if (!j1.isEmpty()) _flags |= IMPLICIT_DISTINCT; j2.joins().removeAll(commonJoins); collectOuterJoins(j1); collectOuterJoins(j2);
/** * Order on a SQL buffer or string. */ private boolean orderBy(Object sql, boolean asc, Joins joins, boolean sel, boolean aliasOrder, Value selAs) { Object order = sql; if (aliasOrder) { order = toOrderAlias(_orders++); _selects.setSelectAs(sql, (String) order); } if ((_flags & RECORD_ORDERED) != 0) { if (_ordered == null) _ordered = new ArrayList(5); _ordered.add(selAs == null ? sql : selAs); } getJoins(joins, true); appendOrdering(selAs != null ? selAs.getAlias() : order, asc); if (sel) { int idx = _selects.indexOfAlias(sql); if (idx == -1) { _selects.setAlias(nullId(), sql, false); return true; } } return false; }
/** * Perform an operation on a column. */ private boolean columnOperation(Column col, boolean sel, Boolean asc, PathJoins pj, boolean aliasOrder) { String as = null; if (asc != null && (aliasOrder || (_flags & RECORD_ORDERED) != 0)) { Object id; if (pj == null || pj.path() == null) id = col; else id = getColumnAlias(col, pj); if ((_flags & RECORD_ORDERED) != 0) { if (_ordered == null) _ordered = new ArrayList(5); _ordered.add(id); } if (aliasOrder) { as = toOrderAlias(_orders++); _selects.setSelectAs(id, as); } } boolean seld = sel && select(col, pj, false); if (asc != null) { String alias = (as != null) ? as : getColumnAlias(col, pj); appendOrdering(alias, asc.booleanValue()); } return seld; }
i = findAliasForQuery(table, pj, key, create); i = findAlias(table, key); i = aliasSize(false, null); recordTableAlias(table, key, i); return i.intValue();
public Joins and(Joins joins1, Joins joins2) { return sel.and(joins1, joins2); }
public void append(SQLBuffer buf, Joins joins) { sel.append(buf, joins); }
public void clearSelects() { sel.clearSelects(); }
public void clearOrdering() { sel.clearOrdering(); }