public LOBBatchQueryWrapper(BatchQuery query) { this.query = query; this.dbAttributes = query.getDbAttributes(); int len = dbAttributes.size(); this.qualifierAttributes = new boolean[len]; this.allLOBAttributes = new boolean[len]; this.updatedLOBAttributes = new Object[len]; indexQualifierAttributes(); }
@Override protected DbAttributeBinding[] createBindings() { List<DbAttribute> dbAttributes = query.getDbAttributes(); int len = dbAttributes.size(); DbAttributeBinding[] bindings = new DbAttributeBinding[len]; for (int i = 0; i < len; i++) { bindings[i] = new DbAttributeBinding(dbAttributes.get(i)); } return bindings; }
Oracle8LOBBatchQueryWrapper(BatchQuery query) { this.query = query; this.dbAttributes = query.getDbAttributes(); int len = dbAttributes.size(); this.qualifierAttributes = new boolean[len]; this.allLOBAttributes = new boolean[len]; this.updatedLOBAttributes = new Object[len]; indexQualifierAttributes(); }
/** * 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, in the order they are * bound to the query. Used mainly for logging. * * @param includeNullValues A <code>true</code> value indicates that the returned * list should include <code>null</code> values and <code>false</code> * indicates they should not be included. * @deprecated Since 1.2 use BatchQueryBuilder.getParameterValues(), as this allows * better control over which attributes are logged. */ public List getValuesForUpdateParameters(boolean includeNullValues) { int len = getDbAttributes().size(); List values = new ArrayList(len); for (int i = 0; i < len; i++) { Object value = getObject(i); if (includeNullValues || value != null) { values.add(value); } } return values; }
@Override List<Object> getValuesForLOBUpdateParameters(BatchQueryRow row) { List<DbAttribute> dbAttributes = query.getDbAttributes(); int len = dbAttributes.size(); List<Object> values = new ArrayList<>(len); for (int i = 0; i < len; i++) { Object value = row.getValue(i); DbAttribute attribute = dbAttributes.get(i); if (isUpdateableColumn(value, attribute.getType())) { values.add(value); } } 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; }
/** * 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; }
/** * Utility method that returns <code>true</code> if the query will update at least * one BLOB or CLOB DbAttribute. * * @deprecated since 1.2 */ public static boolean updatesLOBColumns(BatchQuery query) { boolean isInsert = query instanceof InsertBatchQuery; boolean isUpdate = query instanceof UpdateBatchQuery; if (!isInsert && !isUpdate) { return false; } List updatedAttributes = (isInsert) ? query.getDbAttributes() : ((UpdateBatchQuery) query).getUpdatedAttributes(); Iterator it = updatedAttributes.iterator(); while (it.hasNext()) { int type = ((DbAttribute) it.next()).getType(); if (type == Types.CLOB || type == Types.BLOB) { return true; } } return false; }
/** * Utility method that returns <code>true</code> if the query will update at least * one BLOB or CLOB DbAttribute. * * @since 1.2 */ static boolean updatesLOBColumns(BatchQuery query) { boolean isInsert = query instanceof InsertBatchQuery; boolean isUpdate = query instanceof UpdateBatchQuery; if (!isInsert && !isUpdate) { return false; } List updatedAttributes = (isInsert) ? query.getDbAttributes() : ((UpdateBatchQuery) query).getUpdatedAttributes(); Iterator it = updatedAttributes.iterator(); while (it.hasNext()) { int type = ((DbAttribute) it.next()).getType(); if (type == Types.CLOB || type == Types.BLOB) { return true; } } return false; }
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(); } }
@Override public String createSql(BatchQueryRow row) { List<DbAttribute> dbAttributes = query.getDbAttributes(); QuotingStrategy strategy = adapter.getQuotingStrategy(); StringBuilder buffer = new StringBuilder("INSERT INTO "); buffer.append(strategy.quotedFullyQualifiedName(query.getDbEntity())); buffer.append(" ("); for (Iterator<DbAttribute> i = dbAttributes.iterator(); i.hasNext();) { DbAttribute attribute = i.next(); buffer.append(strategy.quotedName(attribute)); if (i.hasNext()) { buffer.append(", "); } } buffer.append(") VALUES ("); for (int i = 0; i < dbAttributes.size(); i++) { if (i > 0) { buffer.append(", "); } appendUpdatedParameter(buffer, dbAttributes.get(i), row.getValue(i)); } buffer.append(')'); return buffer.toString(); } }
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; }
/** * 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()); } }
@Override protected String createSql() { List<DbAttribute> dbAttributes = query.getDbAttributes(); QuotingStrategy strategy = adapter.getQuotingStrategy();
/** * Utility method that returns <code>true</code> if the query will update at * least one BLOB or CLOB DbAttribute. * * @since 1.2 */ static boolean updatesLOBColumns(BatchQuery query) { boolean isInsert = query instanceof InsertBatchQuery; boolean isUpdate = query instanceof UpdateBatchQuery; if (!isInsert && !isUpdate) { return false; } List<DbAttribute> updatedAttributes = (isInsert) ? query.getDbAttributes() : ((UpdateBatchQuery) query) .getUpdatedAttributes(); for (DbAttribute attr : updatedAttributes) { int type = attr.getType(); if (type == Types.CLOB || type == Types.BLOB) { return true; } } return false; }
@Override List<Object> getValuesForLOBUpdateParameters(BatchQueryRow row) { int len = query.getDbAttributes().size(); UpdateBatchQuery updateBatch = (UpdateBatchQuery) query; List<Object> values = new ArrayList<>(len); List<DbAttribute> qualifierAttributes = updateBatch.getQualifierAttributes(); List<DbAttribute> updatedDbAttributes = updateBatch.getUpdatedAttributes(); int updatedLen = updatedDbAttributes.size(); int qualifierLen = qualifierAttributes.size(); for (int i = 0; i < updatedLen; i++) { DbAttribute attribute = updatedDbAttributes.get(i); Object value = row.getValue(i); if (isUpdateableColumn(value, attribute.getType())) { values.add(value); } } for (int i = 0; i < qualifierLen; i++) { values.add(row.getValue(updatedLen + i)); } return values; }
@Override protected DbAttributeBinding[] createBindings() { List<DbAttribute> attributes = query.getDbAttributes(); int len = attributes.size(); DbAttributeBinding[] bindings = new DbAttributeBinding[len]; for (int i = 0; i < len; i++) { DbAttribute a = attributes.get(i); bindings[i] = new DbAttributeBinding(a); // include/exclude state depends on DbAttribute only and can be // precompiled here if (includeInBatch(a)) { // setting fake position here... all we care about is that it is // > -1 bindings[i].include(1, null, null); } else { bindings[i].exclude(); } } return bindings; }
/** * 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++; } } }