Java & Postgres enums - How do I make them work together for update?

前端 未结 3 495
不思量自难忘°
不思量自难忘° 2020-12-28 16:34

acttype is an enumcs so you can\'t insert it as a normal string without casting it to an enumcs INSERT INTO dir_act (actcode,actname,acttype,national_code) VALUES (?,?

3条回答
  •  难免孤独
    2020-12-28 16:47

    You have to define implicit conversion in Postgres along with your type definition, like below:

    CREATE CAST (varchar AS animal_type) WITH INOUT AS IMPLICIT;
    

    Than you can skip the explicit conversion in insert; so it works also with Spring Data JDBC and other libs that do generate insert query for you.

提交回复
热议问题