private SQLBuffer newSQLBuffer(Select sel, ExpContext ctx, ExpState state) { calculateValue(sel, ctx, state, null, null); SQLBuffer buf = new SQLBuffer(ctx.store.getDBDictionary()); appendTo(sel, ctx, state, buf, 0); return buf; }
/** * Return true if this constant's SQL value is equivalent to NULL. */ public boolean isSQLValueNull(Select sel, ExpContext ctx, ExpState state) { Object val = getSQLValue(sel, ctx, state); if (val == null) return true; if (!(val instanceof Object[])) return false; // all-null array is considered null Object[] arr = (Object[]) val; for (int i = 0; i < arr.length; i++) if (arr[i] != null) return false; return true; }
public void appendTo(Select sel, ExpContext ctx, ExpState state, SQLBuffer buf) { _const.calculateValue(sel, ctx, state, null, null); if (_cls.isInstance(_const.getValue(ctx, state))) buf.append("1 = 1"); else buf.append("1 <> 1"); }
public void orderBy(Select sel, ExpContext ctx, ExpState state, boolean asc) { sel.orderBy(newSQLBuffer(sel, ctx, state), asc, false, getSelectAs()); }
public void acceptVisit(ExpressionVisitor visitor) { visitor.enter(this); _constant.acceptVisit(visitor); visitor.exit(this); }
public void appendIsNull(Select sel, ExpContext ctx, ExpState state, SQLBuffer sql) { if (isSQLValueNull(sel, ctx, state)) sql.append(TRUE); else sql.append(FALSE); }
public void selectColumns(Select sel, ExpContext ctx, ExpState state, boolean pks) { _const.selectColumns(sel, ctx, state, pks); }
public ExpState initialize(Select sel, ExpContext ctx, Map contains) { return _const.initialize(sel, ctx, 0); }
/** * Return the SQL value of this constant. */ public Object getSQLValue(Select sel, ExpContext ctx, ExpState state) { return getValue(ctx, state); }
public void select(Select sel, ExpContext ctx, ExpState state, boolean pks) { sel.select(newSQLBuffer(sel, ctx, state), this); }
public void calculateValue(Select sel, ExpContext ctx, ExpState state, Val other, ExpState otherState) { super.calculateValue(sel, ctx, state, other, otherState); LitExpState lstate = (LitExpState) state; if (other != null) { lstate.sqlValue = other.toDataStoreValue(sel, ctx, otherState,_val); lstate.otherLength = other.length(sel, ctx, otherState); } else lstate.sqlValue = _val; }
public void acceptVisit(ExpressionVisitor visitor) { visitor.enter(this); _const.acceptVisit(visitor); visitor.exit(this); } }
public void appendIsNull(Select sel, ExpContext ctx, ExpState state, SQLBuffer sql) { if (isSQLValueNull(sel, ctx, state)) sql.append(TRUE); else sql.append(FALSE); }
public void selectColumns(Select sel, ExpContext ctx, ExpState state, boolean pks) { _const.selectColumns(sel, ctx, state, pks); }
public ExpState initialize(Select sel, ExpContext ctx, int flags) { return new ConstGetObjectIdExpState(_constant.initialize(sel, ctx, 0)); }
public void orderBy(Select sel, ExpContext ctx, ExpState state, boolean asc) { sel.orderBy(newSQLBuffer(sel, ctx, state), asc, false, getSelectAs()); }
/** * Return the value of this constant. May be more robust than the * parameters-only form. */ public Object getValue(ExpContext ctx, ExpState state) { return getValue(ctx.params); }
public void select(Select sel, ExpContext ctx, ExpState state, boolean pks) { sel.select(newSQLBuffer(sel, ctx, state), this); }
public void calculateValue(Select sel, ExpContext ctx, ExpState state, Val other, ExpState otherState) { super.calculateValue(sel, ctx, state, other, otherState); LitExpState lstate = (LitExpState) state; lstate.mapping = (ClassMapping) getMetaData(); lstate.disc = lstate.mapping.getDiscriminator(); lstate.discValue = lstate.disc != null ? lstate.disc.getValue() : null; sel.select(((ClassMapping) getMetaData()).getPrimaryKeyColumns(), lstate.joins); }
private SQLBuffer newSQLBuffer(Select sel, ExpContext ctx, ExpState state) { calculateValue(sel, ctx, state, null, null); SQLBuffer buf = new SQLBuffer(ctx.store.getDBDictionary()); appendTo(sel, ctx, state, buf, 0); return buf; }