求助:接口参数传入的是json对象数组,如何存储到postgresql数据库jsonb类型字段呢?
1、实体entity,字段类型如何定义呢?
private ListimgUrls;
2、mybatis文件xml属性文件如何定义?
凝练关键词可以到搜索引擎找到大量答案
谢谢指点!根据第一搜索(https://www.cnblogs.com/liangyy/p/13573043.html)方法调整:
1、Entity定义
private Object imgUrls;
2、mybatis plus中xml定义:
<result column="img_urls" property="imgUrls" typeHandler="xx.common.hanlder.JsonTypeHandler" javaType="Object"/>
执行后还是报错如下:
nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='imgUrls', mode=IN, javaType=class java.lang.Object, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #15 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #15 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of java.util.ArrayList. Use setObject() with an explicit Types value to specify the type to use.
<result column="img_urls" property="imgUrls" typeHandler="xxx.common.hanlder.JsonTypeHandler" javaType="Object"/>
<result column="img_urls" property="imgUrls" typeHandler=".common.hanlder.JsonTypeHandler" javaType="Object"/>
<result column="img_urls" property="imgUrls" typeHandler="xx.common.hanlder.JsonTypeHandler" javaType="Object"/>