标签:gsm invoke except jdbc jdb _id values display org
报错详情
org.springframework.dao.DataIntegrityViolationException:
### Error updating database. Cause: java.sql.SQLException: Data truncated for column ‘user_id‘ at row 1
### The error may involve com.joowing.mapper.group.LiveRoomsShareLogsMapper.insertSelective-Inline
### The error occurred while setting parameters
### SQL: insert into live_rooms_share_logs ( org_code, roomid, scene, user_id, phone, guider, path, from_user_id, from_roomid, from_phone, openid, time, dim_date_id, created_at, updated_at ) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
### Cause: java.sql.SQLException: Data truncated for column ‘user_id‘ at row 1
; ]; Data truncated for column ‘user_id‘ at row 1; nested exception is java.sql.SQLException: Data truncated for column ‘user_id‘ at row 1
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:104)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
at com.sun.proxy.$Proxy133.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:278)
at com.baomidou.mybatisplus.core.override.PageMapperMethod.execute(PageMapperMethod.java:67)
at com.baomidou.mybatisplus.core.override.PageMapperProxy.invoke(PageMapperProxy.java:64)
at com.sun.proxy.$Proxy216.insertSelective(Unknown Source)
背景:
小程序端传值过来的user_id字段为188f4ed0-f98a-0137-e415-0242ac1e4810,当因为接口定义不明确,故一开始在建表的时候,习惯性将id类给类long长整型,因为长度不够,插入的时候报错!
解决方案:
此时报错是因为实体类中对于数据库字段长度不够,将数据库中类型变更为String类型并给到255长度对应的model实体类同步变更,解决
衍生报错:
1.检查传入参数是否超过数据库中给定类型长度
2.检查是否存在表字段中数据类型跟实体定义中字段的数据类型不一致的
3.如果对于表字段有过调整,检查mapper.xml文件中的类型是否全部更改清楚的
4.检查数据库链接配置是否串环境的(在本地修改的字段数据,拉了代码后配置被冲掉,连到了其他环境)
5.如若各方检查都感觉无误,重启项目,并清除所在模块下的target文件夹(其中存的是编译后的class文件),排除部分代码更改后未被重现编译的情况
标签:gsm invoke except jdbc jdb _id values display org
原文地址:https://www.cnblogs.com/lwh-note/p/13234855.html