简体   繁体   English

Eclipse给出了我无法理解的错误

[英]Eclipse gives errors I can't understand

I am trying to run some unit tests on a project that has already been developed. 我正在尝试对已经开发的项目运行一些单元测试。 I pulled it on to my system into the git repositories and then built it on the command line. 我将其放入系统中的git存储库中,然后在命令行上进行了构建。 It all succeeded and all the tests run, however, inside eclipse I seem to be getting an error (I think a data error rather than a Java error). 一切都成功了,所有的测试都运行了,但是,在eclipse中,我似乎遇到了一个错误(我认为是数据错误而不是Java错误)。

This is what I think the error message is: 我认为这是错误消息:

org.springframework.dao.DataIntegrityViolationException: Duplicate entry '11' for key 'line_item_ref_number_unique'; org.springframework.dao.DataIntegrityViolationException:键“ line_item_ref_number_unique”的条目“ 11”重复; SQL [n/a]; SQL [n / a]; constraint [null]; 约束[null]; nested exception is org.hibernate.exception.ConstraintViolationException: Duplicate entry '11' for key 'line_item_ref_number_unique' 嵌套的异常是org.hibernate.exception.ConstraintViolationException:键'line_item_ref_number_unique'的重复条目'11'

I am not very good at debugging and would struggle to get to the problem that way. 我不太擅长调试,因此很难以这种方式解决问题。 I will post more code on at request but do not want to bombard the question area with potential unnecessary code. 我将根据要求发布更多代码,但不想用潜在的不必要代码轰炸问题区域。

This might not be very helpful what I have said so far but anyone got any solutions or advice? 到目前为止,这可能对我说的不是很有帮助,但是有人得到任何解决方案或建议吗?

 org.hibernate.exception.ConstraintViolationException: 
 Duplicate entry '11' for key 'line_item_ref_number_unique'

In your database line_item_ref_number_unique is unique key column and you are trying to add duplicate entry in that column so it is giving you ConstraintViolationException . 在您的数据库中, line_item_ref_number_unique是唯一键列,并且您试图在该列中添加重复项,因此它为您提供ConstraintViolationException

don't consider this error as eclipse error it is hibernate exception. 不要将此错误视为eclipse错误,它是休眠异常。
You have to check what you are inserting in your database? 您必须检查要在数据库中插入的内容吗? and why it is duplicate entry? 为什么是重复条目?

You are facing issue ConstraintViolationException its not releated to eclipse environment. 您面临的问题ConstraintViolationException其未发布到Eclipse环境。

Nested exception is org.hibernate.exception.ConstraintViolationException

Please review your database entries and code which is trying to add values. 请检查您试图添加值的数据库条目和代码。

I think you are trying to insert data with primary key which is already in the database or trying to entry duplicate data in unique field. 我认为您正在尝试使用数据库中已经存在的主键插入数据,或者尝试在唯一字段中输入重复数据。 Change that piece of code. 更改那段代码。

For testing purpose you can configure hibernate to re-create the schema every time app start by adding this line in your hibernate config file. 为了进行测试,您可以将hibernate配置为在应用程序每次启动时重新创建架构,方法是在hibernate配置文件中添加此行。

hibernate.hbm2ddl.auto = create | create-drop 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM