无法解决MyBatisSystemException

时间:2018-02-03 12:23:15

标签: java database ibatis

我在myibatis中编写此查询以更新邮政编码值

final String UPDATE ="update table_addresses "
                            + "set postcode= #{postCode}"
                            + "where id in = #{addressId}";

这里addressId是list。在这里传递addressId列表的语法是什么。

目前我收到此错误:

Caused by: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: 
           Could not set parameters for mapping: ParameterMapping{property='addressId', 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 #2 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 #2 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. 
Cause: java.sql.SQLException: Invalid column type

3 个答案:

答案 0 :(得分:1)

根据标准SQL,包含条件应具有以下格式:

SELECT ... FROM ... WHERE id IN (#{addressId})

答案 1 :(得分:1)

您使用=代替() IN。更新您的where子句为 + "where id in ( #{addressId} )";

答案 2 :(得分:0)

使用以下代码:

pool.on('error', (err, client) => {
    console.log('postgres connection error : ' + err)
})