javajooqjooq-codegen

How to convert a Field in jooq custom converter using other fields in the same Record?


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;
    }
}


Solution

  • You probably misunderstood my previous answer. All you do in a Converter is:

    There's no way to achieve what you want to do with a Converter. My previous suggestion of using a Converter was 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.