use of org.apache.cayenne.crypto.transformer.BindingsTransformer 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