PostgreSQL JDBC Null String taken as a bytea

后端 未结 9 618
后悔当初
后悔当初 2020-12-10 02:59

If entity.getHistory() is null following code snippet:

(getEntityManager() returns spring injected EntityManager, database field history type is: text or varchar2(20

9条回答
  •  长情又很酷
    2020-12-10 03:10

    Using Hibernate specific Session API works as a workaround:

    String sql = "INSERT INTO person (id, name) VALUES (:id, :name)";
    Session session = em.unwrap(Session.class);
    SQLQuery insert = session.createSQLQuery(sql);
    sql.setInteger("id", 123);
    sql.setString("name", null);
    insert.executeUpdate();
    

    I've also filed HHH-9165 to report this issue, if it is indeed a bug.

提交回复
热议问题