`
hgq0011
  • 浏览: 561279 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Duplicate key or integrity

阅读更多

在测试hibernate时出现了如下异常:

   [Duplicate key or integrity constraint violation message from server: "Duplicate entry 'rick0@foobar.com' for key 2"]; SQL was [] for task [Hibernate operation]
 org.springframework.dao.DataIntegrityViolationException: Hibernate operation: Duplicate key or integrity constraint violation message from server: "Duplicate entry 'rick0@foobar.com' for key 2"; nested exception is java.sql.SQLException: Duplicate key or integrity constraint violation message from server: "Duplicate entry 'rick0@foobar.com' for key 2"
java.sql.SQLException: Duplicate key or integrity constraint violation message from server: "Duplicate entry 'rick0@foobar.com' for key 2"
 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
 at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)

  这个问题找了很久,晕了很久,终于找到了问题的所在。因我在定义数据表字段时加了not null unique,而我一次添加N条记录时的内容一样,主键是自动生成的,所以出问题了。

分享到:
评论
1 楼 lqw8668 2009-09-23  

相关推荐

Global site tag (gtag.js) - Google Analytics