Hibernate - Custom insert into database

后端 未结 2 851
盖世英雄少女心
盖世英雄少女心 2021-02-08 00:17

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\'))
         


        
2条回答
  •  青春惊慌失措
    2021-02-08 00:39

    Here's a solution:

    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();
    

提交回复
热议问题