/** * @deprecated Since 1.2 renamed to "getValue()" */ public Object getObject(int valueIndex) { return getValue(valueIndex); }
public List getValuesForLOBSelectQualifier() { if (!hasNext) { throw new IllegalStateException("No more rows in the BatchQuery."); } int len = this.qualifierAttributes.length; List values = new ArrayList(len); for (int i = 0; i < len; i++) { if (this.qualifierAttributes[i]) { values.add(query.getValue(i)); } } return values; }
/** * Returns a list of values for the current batch iteration. Used primarily for * logging. * * @since 1.2 */ public List getParameterValues(BatchQuery query) { List attributes = query.getDbAttributes(); int len = attributes.size(); List values = new ArrayList(len); for (int i = 0; i < len; i++) { values.add(query.getValue(i)); } return values; } }
/** * Returns a list of values for the current batch iteration. Performs filtering of * attributes based on column generation rules. Used primarily for logging. * * @since 1.2 */ public List getParameterValues(BatchQuery query) { List attributes = query.getDbAttributes(); int len = attributes.size(); List values = new ArrayList(len); for (int i = 0; i < len; i++) { DbAttribute attribute = (DbAttribute) attributes.get(i); if (includeInBatch(attribute)) { values.add(query.getValue(i)); } } return values; }
public List getValuesForLOBUpdateParameters(BatchQuery query) { List dbAttributes = query.getDbAttributes(); int len = dbAttributes.size(); List values = new ArrayList(len); for (int i = 0; i < len; i++) { Object value = query.getValue(i); DbAttribute attribute = (DbAttribute) dbAttributes.get(i); if (isUpdateableColumn(value, attribute.getType())) { values.add(value); } } return values; }
public List getValuesForLOBUpdateParameters(BatchQuery query) { int len = query.getDbAttributes().size(); UpdateBatchQuery updateBatch = (UpdateBatchQuery) query; List values = new ArrayList(len); List qualifierAttributes = updateBatch.getQualifierAttributes(); List updatedDbAttributes = updateBatch.getUpdatedAttributes(); int updatedLen = updatedDbAttributes.size(); int qualifierLen = qualifierAttributes.size(); for (int i = 0; i < updatedLen; i++) { DbAttribute attribute = (DbAttribute) updatedDbAttributes.get(i); Object value = query.getValue(i); if(isUpdateableColumn(value, attribute.getType())) { values.add(value); } } for (int i = 0; i < qualifierLen; i++) { values.add(query.getValue(updatedLen + i)); } return values; }
public String createSqlString(BatchQuery batch) { String table = batch.getDbEntity().getFullyQualifiedName(); List dbAttributes = batch.getDbAttributes(); StringBuffer query = new StringBuffer("INSERT INTO "); query.append(table).append(" ("); for (Iterator i = dbAttributes.iterator(); i.hasNext();) { DbAttribute attribute = (DbAttribute) i.next(); query.append(attribute.getName()); if (i.hasNext()) { query.append(", "); } } query.append(") VALUES ("); for (int i = 0; i < dbAttributes.size(); i++) { if (i > 0) { query.append(", "); } appendUpdatedParameter( query, (DbAttribute) dbAttributes.get(i), batch.getValue(i)); } query.append(')'); return query.toString(); } }
appendUpdatedParameter(query, attribute, batch.getValue(i));
/** * Binds parameters for the current batch iteration to the PreparedStatement. * * @since 1.2 */ public void bindParameters(PreparedStatement statement, BatchQuery query) throws SQLException, Exception { List dbAttributes = query.getDbAttributes(); int attributeCount = dbAttributes.size(); for (int i = 0; i < attributeCount; i++) { Object value = query.getValue(i); DbAttribute attribute = (DbAttribute) dbAttributes.get(i); adapter.bindParameter(statement, value, i + 1, attribute.getType(), attribute .getPrecision()); } }
/** * Indexes attributes */ protected void indexLOBAttributes() { int len = updatedLOBAttributes.length; for (int i = 0; i < len; i++) { updatedLOBAttributes[i] = null; if (allLOBAttributes[i]) { // skip null and empty LOBs Object value = query.getValue(i); if (value == null) { continue; } if (((DbAttribute) dbAttributes.get(i)).getType() == Types.BLOB) { updatedLOBAttributes[i] = convertToBlobValue(value); } else { updatedLOBAttributes[i] = convertToClobValue(value); } } } }
/** * Binds BatchQuery parameters to the PreparedStatement. */ public void bindParameters(PreparedStatement statement, BatchQuery query) throws SQLException, Exception { DeleteBatchQuery deleteBatch = (DeleteBatchQuery) query; List qualifierAttributes = deleteBatch.getQualifierAttributes(); int parameterIndex = 1; for (int i = 0; i < qualifierAttributes.size(); i++) { Object value = query.getValue(i); DbAttribute attribute = (DbAttribute) qualifierAttributes.get(i); // skip null attributes... they are translated as "IS NULL" if (deleteBatch.isNull(attribute)) { continue; } adapter.bindParameter( statement, value, parameterIndex++, attribute.getType(), attribute.getPrecision()); } } }
/** * Binds parameters for the current batch iteration to the PreparedStatement. Performs * filtering of attributes based on column generation rules. * * @since 1.2 */ public void bindParameters(PreparedStatement statement, BatchQuery query) throws SQLException, Exception { List dbAttributes = query.getDbAttributes(); int attributeCount = dbAttributes.size(); // must use an independent counter "j" for prepared statement index for (int i = 0, j = 0; i < attributeCount; i++) { DbAttribute attribute = (DbAttribute) dbAttributes.get(i); if (includeInBatch(attribute)) { j++; Object value = query.getValue(i); adapter.bindParameter(statement, value, j, attribute.getType(), attribute .getPrecision()); } } }
/** * Binds BatchQuery parameters to the PreparedStatement. */ public void bindParameters(PreparedStatement statement, BatchQuery query) throws SQLException, Exception { List dbAttributes = query.getDbAttributes(); int attributeCount = dbAttributes.size(); // i - attribute position in the query // j - PreparedStatement parameter position (starts with "1") for (int i = 0, j = 1; i < attributeCount; i++) { Object value = query.getValue(i); DbAttribute attribute = (DbAttribute) dbAttributes.get(i); int type = attribute.getType(); // TODO: (Andrus) This works as long as there is no LOBs in qualifier if (isUpdateableColumn(value, type)) { adapter .bindParameter(statement, value, j, type, attribute .getPrecision()); j++; } } }