Hi,
I'm having a problem when inserting into a MySQL database with this error:
Cannot add or update a child row: a foreign key constraint fails
because I'm trying to insert a Hibernate Entity which is associated with a Table (the child one) with a foreign key referencing parent table.
The issue is that I'm making some tests and I don't want to make the class for the parent table yet.
Is there any way in which I could just insert a "null" value in the foreign key (the relation is optional) without having to code the other class and without making the annotations @OneToMany and ManyToOne?
When I make the INSERT from the mysql command-line with the foreign key value = null there is no problem, but strangely it does shows the former error on Hibernate.
I've searched for some similar problem, but every example uses two classes.
Thank you.
Last edited by madtyn on Sun Sep 04, 2011 12:15 pm, edited 1 time in total.
|