I'm getting this error when trying to save data into a table that contains foreign key columns.
This is my scenario I'm picking two options from two different ComboBoxes (one option from each different ComboBox), I write two strings, all this to build my object to save but when committing I get this error:
WARN SqlExceptionHelper - SQL Error: 1452, SQLState: 23000 ERROR SqlExceptionHelper - Cannot add or update a child row: a foreign key constraint fails (
students
.student
, CONSTRAINTfk_student_career
FOREIGN KEY (student_career
) REFERENCEScareer
(career_name
) ON DELETE NO ACTION ON UPDATE NO ACTION) ERROR ExceptionMapperStandardImpl - HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]
These are my classes I placed them in my gists repositories to make this post a little bit short.
I have followed many tutorials and read a lot of info but can't manage to make it work. I have used the cascadetype, JoinColumn and many other things but failed in all...
Please help me...
P.S.: I'm self-learning and this a practice.