I am new with Hibernate and encountered an issue, I will describe it through a short example because the involved classes and tables are parts of a very complex project from where is a little difficult to take out the code. In the project Hibernate 3.3.1 is used.
We have 2 tables: ParentTable and ChildTable.
ParentTable has: Parent_Id (primary key) and some other fields (which are not interesting for us)
ChildTable has: Parent_Id (foreign key from ParentTable), Field1, Field2. (FK_Parent_id and Field1) are the primary key for this table, so in the DB we have a Unique index for these fields.
Basically on the GUI I have a form with many fields (for Parent) and have a grid (which has 2 columns: Field1 and Field2) and can contain several rows (for child).
The problem is that if I remove a row from this grid the delete doesn’t work from the DB, the value is put back and it is showed again on the GUI. Only inserts and update works as expected.
I read a couple of articles, forums, a few chapters from hibernate books but none of the solutions worked, does somebody has any idea of what can I change or what is wrong?
I debugged the code and noticed that Hibernate generated an update instead of delete, it tries to update the foreign key (which also belongs to the primary key) to null, which of course is not possible.