When using mybaits plus update data times wrong:
2018-09-05 10: 55: 40.712 DEBUG 15828 --- [nio-8110-exec-1] ccxsmAupdateAllColumnById: ==> Preparing: UPDATE ais0060 SET TENANT_ID = ?, LIFNR = ?, NAME1 = ?, ORT01 =? , TELF1 = ?, del_flag = ?, remarks = ?, create_by = ?, create_date = ?, update_by = ?, update_date =? WHERE id =?
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping {property = 'et.tenantId', 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 null for parameter # 1 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: invalid column type: 1111
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible (MyBatisExceptionTranslator.java:77)
at org.mybatis.spring.SqlSessionTemplate $ SqlSessionInterceptor.invoke (SqlSessionTemplate.java:446)
at com.sun.proxy. $ Proxy124.update (Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.update (SqlSessionTemplate.java:294)
at org.apache.ibatis.binding.MapperMethod.execute (MapperMethod.java:62)
The original because the tenant_id field is null.
Most of the reasons for the MyBatis to modify the SQL syntax in XML, but the MyBatis plus base crud does not require handwritten SQL, the whole day, to find a solution:
/ **
* Tenant ID
* /
@TableField (value = "TENANT_ID", el = "tenantId, jdbcType = VARCHAR")
private String tenantId;
In the @tablefield annotation, add {object. property}. At the same time, more usage of el:
/ **
* <p>
* When the Field is a class object, you can use # {Object.Attribute} to map to the data table.
* </ p>
* <p>
* Support: @TableField (el = "role, jdbcType = BIGINT) <br>
* Support: @TableField (el = "role, typeHandler = com.baomidou.springcloud.typehandler.PhoneTypeHandler")
* </ p>
* /
String el () default "";
MyBatis Write SQL statement modification method see: 45369611
Jdbctype introduction See also: https://www.cnblogs.com/tongxuping/p/7134113.html
Java.sql.SQLException: Invalid column type: 1111