当前使用版本(必须填写清楚,否则不予处理)
3.2.0
该问题是怎么引起的?(最新版上已修复的会直接close掉)
Postgresql 数据库字段是Jsonb 时候,使用BaseMapper的方法查询报错 但如果是在mapper 定义查询是不会报错的 @Select("select * from xcx_mini WHERE app_id @> '[\"3\"]'") Mini getOneByJSONB();
重现步骤
mapper文件
<resultMap id="mini" type="com.zhiyi.miniapp.entity.Mini" autoMapping="true">
…..
<result column="app_id" property="appId" javaType="Object" jdbcType="OTHER" typeHandler="com.zhiyi.miniapp.general.nosql.handler.JSONTypeHandler"/>
</resultMap>
报错信息
Error querying database. Cause: org.postgresql.util.PSQLException: ERROR: operator does not exist: jsonb = character varying
Hint: No operator matches the given name and argument types. You might need to add explicit type casts. Position: 176
The error may exist in com/zhiyi/miniapp/mapper/MiniMapper.java (best guess)
The error may involve defaultParameterMap
The error occurred while setting parameters
SQL: SELECT id, update_user, update_time, user_id, is_deleted, create_dept, create_time, app_id, name, tenant_id, json, create_user, design_json, status FROM xcx_mini WHERE app_id = ? AND is_deleted = 0
Cause: org.postgresql.util.PSQLException: ERROR: operator does not exist: jsonb = character varying
Hint: No operator matches the given name and argument types. You might need to add explicit type casts. Position: 176 ; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: operator does not exist: jsonb = character varying Hint: No operator matches the given name and argument types. You might need to add explicit type casts. Position: 176
Comment From: kong6001
已解决 属性添加注解 @TableField(typeHandler = JSONBTypeHandler.class)
Comment From: GongZhengMe
已解决 属性添加注解 @TableField(typeHandler = JSONBTypeHandler.class)
请问JSONBTypeHandler.class是自己写的还是Mybatis Plus自带的,我的是3.3.0,没有这个类