// 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, getAdapter(), getEntityResolver());
action.setBatch(runningAsBatch);
action.performAction(connection, observer);
}