Hibernate version: 2.1.2
Is there a way to specify a formula for writing data? I realize the formula attribute of a property can be used for "computed" properties, but what about computing the value that will be inserted?
A specific (and I think common) use case would be encrypting/decrypting functions.
On read, I would like to use the db function decrypt(dbvalue).
On write, I would like to use the db function encrypt(javavalue).
So that ultimately: the java object only ever contains unencrypted values, and the db only ever contains encrypted values.
I think I can get around this using 2 properties (1 mapped as formula, and 1 mapped as a "normal" property; the written unencrypted value will updated using a separate db call during flush via interceptor), but it is far from elegant.
A user type could also work, but similarly there would need to be a extra db call for each read, and for each write.
Thanks for any advice!
Tyson
|