在kafka发送消息到另一个service,service执行sql, 首次或前2次执行正常C操作,但后续2次或以后的操作必然发生以下错误:

### Error updating database.  Cause:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
Duplicate entry '93' for key 'PRIMARY'
### The error may exist in
com/crossoverjie/kafka/orderconsumer/mapper/StockOrderMapper.java (best guess)
### The error may involve
com.crossoverjie.kafka.orderconsumer.mapper.StockOrderMapper.insertSelective-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO stock_order  ( id,sid,name ) VALUES( ?,?,? )
### Cause:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
Duplicate entry '93' for key 'PRIMARY'
; SQL []; Duplicate entry '93' for key 'PRIMARY'; nested exception is
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
Duplicate entry '93' for key 'PRIMARY'

2018-05-21 16:38:31.273 [consumer-pool-0] TRACE o.s.t.i.TransactionInterceptor
- Completing transaction for
[com.crossoverjie.kafka.orderconsumer.service.impl.OrderServiceImpl.createOptimisticOrderUseRedisAndKafka]
after exception: java.lang.RuntimeException: 

根据错误提示,说已存在主键id=93这条数据,不能再插入了,正常理解是93是已存在了,为啥新插入id自增的怎么没自动累加呢?

我们的pojo设置了主键id注解

去掉就好了

技术
©2019-2020 Toolsou All rights reserved,
el-ui:select获取值关于Bellman-Ford算法的个人理解vue vue-element-admin项目踩坑小结ElementUI中获取select 的label值org.postgresql.util.PSQLException 处理记录【答学员问】你们从培训机构毕业后都找到什么工作?Python 读取Excel某一列|转存json华为鸿蒙操作系统有哪些特点和优势?余承东《全场景时代 新体验与新生态》演讲全文 Unity3D Input按键系统keras数据生成器--数据增强