/** * 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; } }
@Override protected String createSql() { QuotingStrategy strategy = adapter.getQuotingStrategy(); StringBuilder buffer = new StringBuilder("UPDATE "); buffer.append(strategy.quotedFullyQualifiedName(query.getDbEntity())); buffer.append(" SET ").append(strategy.quotedIdentifier(query.getDbEntity(), deletedFieldName)).append(" = ?"); applyQualifier(buffer); return buffer.toString(); }
/** * 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; }
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(); } }
public String createSqlString(BatchQuery batch) { String table = batch.getDbEntity().getFullyQualifiedName(); List dbAttributes = batch.getDbAttributes();
boolean useOptimisticLock = query.isUsingOptimisticLocking(); query.reset(); Statement.RETURN_GENERATED_KEYS) : connection.prepareStatement(queryStr); try { while (query.next()) { if (isLoggable) { QueryLogger.logQueryParameters("bind", queryBuilder query.getDbEntity(), queryStr, snapshot);
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(); }
public SQLAction batchAction(BatchQuery query) { // check run strategy... // optimistic locking is not supported in batches due to JDBC driver limitations boolean useOptimisticLock = query.isUsingOptimisticLocking(); boolean runningAsBatch = !useOptimisticLock && adapter.supportsBatchUpdates(); BatchAction action = new BatchAction(query, adapter, entityResolver); action.setBatch(runningAsBatch); return action; }
/** * Executes batch as individual queries over the same prepared statement. */ protected void runAsIndividualQueries(Connection connection, BatchTranslator translator, OperationObserver delegate, boolean generatesKeys) throws SQLException, Exception { JdbcEventLogger logger = dataNode.getJdbcEventLogger(); boolean useOptimisticLock = query.isUsingOptimisticLocking(); String queryStr = translator.getSql(); // log batch SQL execution logger.log(queryStr); // run batch queries one by one DbAdapter adapter = dataNode.getAdapter(); try (PreparedStatement statement = prepareStatement(connection, queryStr, adapter, generatesKeys)) { for (BatchQueryRow row : query.getRows()) { DbAttributeBinding[] bindings = translator.updateBindings(row); logger.logQueryParameters("bind", bindings); bind(adapter, statement, bindings); int updated = statement.executeUpdate(); if (useOptimisticLock && updated != 1) { throw new OptimisticLockException(row.getObjectId(), query.getDbEntity(), queryStr, row.getQualifier()); } delegate.nextCount(query, updated); if (generatesKeys) { processGeneratedKeys(statement, delegate, row); } logger.logUpdateCount(updated); } } }
public String createSqlString(BatchQuery batch) { UpdateBatchQuery updateBatch = (UpdateBatchQuery) batch; String table = batch.getDbEntity().getFullyQualifiedName(); List idDbAttributes = updateBatch.getQualifierAttributes(); List updatedDbAttributes = updateBatch.getUpdatedAttributes(); appendUpdatedParameter(query, attribute, batch.getValue(i));
ObjectId id = batch.getObjectId(); if (id == null || !id.isTemporary()) { Iterator it = batch.getDbEntity().getGeneratedAttributes().iterator(); while (it.hasNext()) { DbAttribute attribute = (DbAttribute) it.next();
Collection<DbAttribute> generated = query.getDbEntity().getGeneratedAttributes(); if (generated.size() == 1) { DbAttribute key = generated.iterator().next(); RowReader<?> rowReader = dataNode.rowReader(keyRowDescriptor, query.getMetaData(dataNode.getEntityResolver()), Collections.<ObjAttribute, ColumnDescriptor> emptyMap()); ResultIterator iterator = new JDBCResultIterator(null, keysRS, rowReader);
/** * @deprecated Since 1.2 renamed to "getValue()" */ public Object getObject(int valueIndex) { return getValue(valueIndex); }
for (BatchQueryRow row : query.getRows()) {
public boolean next() { hasNext = query.next(); if (hasNext) { indexLOBAttributes(); } return hasNext; }
ObjectId id = getObjectId(); if (id != null) {
query.reset(); while (selectQuery.next()) { int updated = 0;
@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(); } }
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(); }