- Need to apply custom field conversion logic in
org.jooq.Converterimplementation. - The custom conversion is a encrypt / decrypt the field
- The key for encryption / decryption will be available in the same
org.jooq.RecordContexti.e: In the same table another column will have key.
If below is not possible what are the other ways to achieve this?
public class CustomFieldConverter implements Converter<String, String> {
@Override
public String from(String databaseObject) {
// do MySQLDSL.aesDecrypt(databaseObject, Field('keyColumn')
// How to access keyColumn field here?
//
}
@Override
public String to(String userObject) {
// do MySQLDSL.aesEncrypt(databaseObject, Field('keyColumn')
// How to access keyColumn field here?
}
@Override
public Class<String> fromType() {
return String.class;
}
@Override
public Class<String> toType() {
return String.class;
}
}
You probably misunderstood my previous answer. All you do in a
Converteris:There's no way to achieve what you want to do with a
Converter. My previous suggestion of using aConverterwas meant to hint at doing all the encryption / decryption completely in the client, not partially in the client. This means you have to have that key available in memory to do any encryption / decryption using Java API, not using MySQL API.