Java.sql.SQLException: Invalid column type: 1111

Source: Internet
Author: User



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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.