use of org.apache.cayenne.access.translator.batch.BatchTranslator in project cayenne by apache.
the class BatchAction method performAction.
@Override
public void performAction(Connection connection, OperationObserver observer) throws SQLException, Exception {
BatchTranslator translator = createTranslator();
boolean generatesKeys = hasGeneratedKeys();
if (runningAsBatch && !generatesKeys) {
runAsBatch(connection, translator, observer);
} else {
runAsIndividualQueries(connection, translator, observer, generatesKeys);
}
}
use of org.apache.cayenne.access.translator.batch.BatchTranslator in project cayenne by apache.
the class CryptoBatchTranslatorFactoryDecorator method translator.
@Override
public BatchTranslator translator(BatchQuery query, final DbAdapter adapter, String trimFunction) {
final BatchTranslator delegateTranslator = delegate.translator(query, adapter, trimFunction);
return new BatchTranslator() {
private boolean encryptorCompiled;
private BindingsTransformer encryptor;
private void ensureEncryptorCompiled() {
if (!encryptorCompiled) {
encryptor = cryptoFactory.encryptor(getBindings(), adapter.getExtendedTypes());
encryptorCompiled = true;
}
}
@Override
public String getSql() {
return delegateTranslator.getSql();
}
@Override
public DbAttributeBinding[] getBindings() {
return delegateTranslator.getBindings();
}
@Override
public DbAttributeBinding[] updateBindings(BatchQueryRow row) {
ensureEncryptorCompiled();
DbAttributeBinding[] bindings = delegateTranslator.updateBindings(row);
if (encryptor != null) {
encryptor.transform(bindings);
}
return bindings;
}
};
}
Aggregations