Hi,
I am facing a problem with delete operation. My DB schema is like this
Entity A
---------
Pk - FacilityId
Some other fields
Entity B
--------
Pk - FieldId
Some other fields
Join Table C
--------------
Pk- FacilityId, FieldId
FacilityId references A.FacilityId
FieldId references B.FieldId
Some other fields
My classes are class A with FacilityId as id, class B with FieldId as id, class C with Class D as id, class D with classA, class B as the Id.
I declared a set object in class A with one-to-many relationship for class C. Inserting class C objects into the set is working perfectly fine and rows are inserted into C. But when I invoke clear function on the set, the rows are not getting deleted and it says that a foreign key constraint fails in table C. I read this somewhere and tried to make key element of the set in Entity A's mapping file to not-null = "true" but then an exception is generated saying that
Repeated column in mapping for entity class C, FacilityId should be mapped with insert="false" , update="false". I can only declare update="false" as an attribute of the key element. Where should I put insert attribute?. Only putting update generates the same exception.
What is the correct way to delete objects. Please give some advice.
Thanks in advance
Phani
|