我正在尝试对已经开发的项目运行一些单元测试。我将它拉到我的系统中的 git 存储库中,然后在命令行上构建它。一切都成功了,所有的测试都运行了,但是,在 eclipse 中我似乎收到了一个错误(我认为是数据错误而不是 Java 错误)。
这就是我认为的错误消息:
org.springframework.dao.DataIntegrityViolationException: Duplicate entry '11' for key 'line_item_ref_number_unique'; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Duplicate entry '11' for key 'line_item_ref_number_unique'
我不太擅长调试,并且很难以这种方式解决问题。 我将根据要求发布更多代码,但不想用潜在的不必要的代码轰炸问题区域。
到目前为止我所说的可能不是很有帮助,但是有人有任何解决方案或建议吗?
最佳答案
org.hibernate.exception.ConstraintViolationException:
Duplicate entry '11' for key 'line_item_ref_number_unique'
在您的数据库中,line_item_ref_number_unique
是唯一的键列,并且您尝试在该列中添加重复的条目,因此它会给您ConstraintViolationException
。
不要将此错误视为 Eclipse 错误,它是 hibernate 异常。
您必须检查您在数据库中插入的内容?为什么是重复条目?
关于java - Eclipse 给出了我无法理解的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27600226/