/** * Gets input value corrsponding to given columnRef from given updateDesc * * @param updateDesc updateDesc pointing to the input values * @param columnRef The columnRef. It always contains the <code>LocalFieldDesc</code> for the * field. * @param getBeforeValue If true, value returned is fetched from beforeImage if false, the value * returned is fetched from afterImage. * @return input value corrsponding to given columnRef from given updateDesc. */ private static Object getInputValue( UpdateObjectDescImpl updateDesc, ColumnRef columnRef, boolean getBeforeValue) { Object value; LocalFieldDesc field = (LocalFieldDesc) columnRef.getValue(); if (field.isVersion()) { // Bind the value from the after image for version fields, // as they're incremented internally after each flush. // Version fields must not be modified from "outside". value = updateDesc.getAfterValue(field); } else { value = getBeforeValue ? updateDesc.getBeforeValue(field) : updateDesc.getAfterValue(field); } return value; }
private StringBuffer generateColumnText() { StringBuffer columnList = new StringBuffer(); int numValues = -1; for (int i = 0; i < columns.size(); i++) { ColumnRef c = (ColumnRef) columns.get(i); if (columnList.length() > 0) { columnList.append(", "); // NOI18N } switch (action) { case QueryPlan.ACT_UPDATE: appendQuotedText(columnList, c.getName()); columnList.append("= ?"); // NOI18N break; case QueryPlan.ACT_INSERT: appendQuotedText(columnList, c.getName()); if (i == 0) { values = new StringBuffer().append(" ?"); // NOI18N } else { values.append(", ?"); // NOI18N } break; } // Do not create an InputValue in the case of batch update. // Method bindInputValues will get the value using the ColumnRef. if (!batch && ((action == QueryPlan.ACT_UPDATE) || (action == QueryPlan.ACT_INSERT))) { numValues = numValues + 1; InputValue val = new InputValue(c.getValue(), c.getColumnElement()); inputDesc.values.add(numValues, val); } } appendVersionColumnUpdateClause(columnList); return columnList; }