Mybatis操作PgSQL的JSON類型(org.postgresql.util.PSQLException: ERROR: column "destination" is of type json but expression is of type character varying) JSON問題


Mybatis操作PgSQL的JSON類型


Mybatis在保存json類型字段時報錯:

SQL: UPDATE viewing_angle  SET name=?, destination=?, orientation=?  WHERE id=?
### Cause: org.postgresql.util.PSQLException: ERROR: column "destination" is of type json but expression is of type character varying
  建議:You will need to rewrite or cast the expression.
  位置:48
; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: column "destination" is of type json but expression is of type character varying
  建議:You will need to rewrite or cast the expression.


解決方法:可以再jdbc連接后面增加stringtype=unspecified來把JSON類型當STRING類型存儲

spring.datasource.url=jdbc:postgresql://192.168.8.190:5432/oyz_3d_server?stringtype=unspecified


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM