当前使用版本(必填,否则不予处理)
mybatis plus版本:3.2.0 sharding-jdbc:4.0.0-RC1
该问题是如何引起的?(确定最新版也有问题再提!!!)
mybatis plus主键策略设置如下: global-config: #主键类型 1:"数据库ID自增", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID"; id-type: 2 sharding-jdbc主键策略: bean的id属性: type=IdType.input SNOWFLAKE 使用mybatis plus连接sharding-jdbc,插入数据时会报如下错误: java.lang.StringIndexOutOfBoundsException: String index out of range: -8 但如果不使用mybatis plus的save方法,手写sql,就不会有问题
重现步骤(如果有就写完整)
//orderService.save(order);---mybatis plus的save方法(会报错) orderMapper.addTOrder(order);---手写sql,没问题
报错信息
Error updating database. Cause: java.lang.StringIndexOutOfBoundsException: String index out of range: -8
The error may exist in com/crazyzhou/shardingjdbc/dao/OrderMapper.java (best guess)
The error may involve com.crazyzhou.shardingjdbc.dao.OrderMapper.insert-Inline
The error occurred while setting parameters
SQL: INSERT INTO public.t_order ( order_id, order_content ) VALUES ( ?, ? )
Cause: java.lang.StringIndexOutOfBoundsException: String index out of range: -8] with root cause
Comment From: miemieYaho
id-type: input
Comment From: CrazyZhou0708
我使用的就是Input属性
Comment From: Wangshuhong123
请教下你最后是怎么解决的