This, of course, can be done using your own SQL query. Or, if you want to use HQL, it should be possible to expand the MySQL dialogs and register functions (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.
There are also Jasypt UserTypes depending on your specific needs (although does the Jasypt site seem down / dead?)
source share