hibernate - Use spring property in @ColumnTransformer -
i try use database encryption single fields spring , jpa (hibernate). here part of entity:
@columntransformer( read="aes_decrypt(unhex(lastname), unhex(sha2('secret', 512)))", write="hex(aes_encrypt(?, unhex(sha2('secret', 512))))" ) private string lastname;
this uses mysql-functions encrypt , decrypt field, not have care in java.
my problem cannot hardcode passphrase in java-code, java-annotations allow non-dynamic final strings params. how use spring application property replace passphrase 'secret'
?
i cannot use jpa-converter, because want able filter , sort lastname
. tried subclass mysql5innodbdialect , register standardsqlfunction
, not work conceptually @columntransformer
because these functions registered in context of jpa, not sql. thought of programmatically manipulating hibernate config before used create entitymanagerfactory, not know how that. appreciated.
Comments
Post a Comment