I write this post to know if someone knows how to do this:
I want to do this insert:
INSERT INTO TABLA (CAMPO1, CAMPO2) VALUES (?, crypt(?,\'cdp\'))
Like Nathan Feger mentioned, named parameters are much cleaner and safer. In this case, the statement can be executed with the following code:
Query query = getSession().createSQLQuery("INSERT INTO TABLA (CAMPO1, CAMPO2) VALUES (:valor1, encripta(:valor2, :key))");
query.setParameter("valor1", valor1);
query.setParameter("valor2", valor2);
query.setParameter("key", key);
query.executeUpdate();