简体   繁体   中英

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. 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).

This is what I think the error message is:

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'

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 .

don't consider this error as eclipse error it is hibernate exception.
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.

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.hbm2ddl.auto = create | create-drop 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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