public void setNonNullParameter(PreparedStatement ps, int i, JSONObject parameter, JdbcType jdbcType) throws SQLException {
jsonObject.setType("json"); // 这一行添加断点,检查 update 是否经过这边
jsonObject.setValue(parameter.toString());
ps.setObject(i, jsonObject);
}
### 详细堆栈日志
```bash
Caused by: org.apache.ibatis.type.TypeException: Error setting non null for parameter #1 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 #1 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: org.postgresql.util.PSQLException: No hstore extension installed.
at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:76)
at com.baomidou.mybatisplus.core.MybatisParameterHandler.setParameters(MybatisParameterHandler.java:296)
... 209 common frames omitted
Caused by: org.apache.ibatis.type.TypeException: Error setting non null for parameter #1 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: org.postgresql.util.PSQLException: No hstore extension installed.
at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:76)
at org.apache.ibatis.type.UnknownTypeHandler.setNonNullParameter(UnknownTypeHandler.java:71)
at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:74)
... 210 common frames omitted
Caused by: org.postgresql.util.PSQLException: No hstore extension installed.
at org.postgresql.jdbc.PgPreparedStatement.setMap(PgPreparedStatement.java:559)
at org.postgresql.jdbc.PgPreparedStatement.setObject(PgPreparedStatement.java:1063)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.setObject(HikariProxyPreparedStatement.java)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:67)
at jdk.proxy3/jdk.proxy3.$Proxy121.setObject(Unknown Source)
at org.apache.ibatis.type.ObjectTypeHandler.setNonNullParameter(ObjectTypeHandler.java:31)
at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:74)
... 212 common frames omitted
确认
当前程序版本
3.5.5
问题描述
详情见:https://blog.csdn.net/xiaosi_xiaosi/article/details/138540152
定义的PG数据库对象
自定义 JSON Handler
import com.alibaba.fastjson2.JSONObject; import org.apache.ibatis.type.BaseTypeHandler; import org.apache.ibatis.type.JdbcType; import org.apache.ibatis.type.MappedTypes; import org.postgresql.util.PGobject;
import java.sql.CallableStatement; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException;
@MappedTypes(JSONObject.class) public class JSONTypeHandler extends BaseTypeHandler {
}
public boolean update(String id, JSONObject content) { LambdaUpdateWrapper lambdaUpdate = new LambdaUpdateWrapper<>();
lambdaUpdate.eq(DemoPO::getId, id)
lambdaUpdate.set(DemoPO::getContent, content);
return update(lambdaUpdate);
}