How can I execute this query in hibernate?
SELECT AES_ENCRYPT('admin','password')
How can I execute this query in hibernate?
SELECT AES_ENCRYPT('admin','password')
This should be of course doable using a Native SQL Query. Or, if you want to use HQL, it should be possible to extend the MySQL dialect and to register the function(s) (not tested):
registerFunction("aes_encrypt", new StandardSQLFunction("aes_encrypt", Hibernate.STRING) )
registerFunction("aes_decrypt", new StandardSQLFunction("aes_decrypt", Hibernate.STRING) )
Obviously, in both cases, this is not portable.
Depending on your exact needs, there are also Jasypt UserTypes (altough the Jasypt site seems to be down/dead?)