Reputation: 393
I am writing this query in myibatis for updating postcode values
final String UPDATE ="update table_addresses "
+ "set postcode= #{postCode}"
+ "where id in = #{addressId}";
Here addressId is list.what is the syntax to pass List of addressId's here.
Currently I am getting this error:
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
Upvotes: 1
Views: 1505
Reputation: 83
Use below code:
final String UPDATE = "update table_addresses "
+ "set postcode= #{postCode}"
+ "where id in = #{addressId,jdbcType=ARRAY}";
Upvotes: 0
Reputation: 3078
You are using =
instead of ()
for IN
.Update your where clause as
+ "where id in ( #{addressId} )";
Upvotes: 1
Reputation: 8783
According to standard SQL, an inclusion condition should have this format:
SELECT ... FROM ... WHERE id IN (#{addressId})
Upvotes: 1