I have a Parent Table A and child tables B,C with many to one relations.
Lets say I have data like, for primary key 1 in parent table A I have 3 rows in child table B and 4 rows in child table C.
Now if I want to delete the rows of the child table during an update of the parent table(that means Now, I want to update the table only with one row in each child tables and delete the other rows in them) then how to handle this scenario in hibernate?
Update
Firstly, sorry that my question was unclear. Here are more details of it.
I have a parent table Policy
CREATE TABLE "DEV2"."POLICY" ( "POLICY_OID" NUMBER(38,0) NOT NULL ENABLE, "CREATED_DATE" TIMESTAMP (0) NOT NULL ENABLE, "EFFECTIVE_DATE" TIMESTAMP (0), "UPDATED_DATE" TIMESTAMP (0), "STATUS" VARCHAR2(32 BYTE), CONSTRAINT "PK128" PRIMARY KEY ("POLICY_OID") , CONSTRAINT "REFPOLICY_CLASS290" FOREIGN KEY ("POLICY_CLASS") REFERENCES "DEV2"."POLICY_CLASS" ("POLICY_CLASS_REF") ENABLE )
and @OneToMany relation to child table POLICY_RELATIONSHIP
CREATE TABLE "DEV2"."POLICY_RELATIONSHIP" ( "POLICY_RELATIONSHIP_OID" NUMBER(38,0) NOT NULL ENABLE, "POLICY_ACTOR" NUMBER(38,0) NOT NULL ENABLE, "POLICY_ACTOR_TYPE" VARCHAR2(32 BYTE) NOT NULL ENABLE, "POLICY_OID" NUMBER(38,0) NOT NULL ENABLE, CONSTRAINT "PK156" PRIMARY KEY ("POLICY_RELATIONSHIP_OID") , CONSTRAINT "REFPOLICY338" FOREIGN KEY ("POLICY_OID") REFERENCES "DEV2"."POLICY" ("POLICY_OID") ENABLE)
For Example, I have the sample data something like this.
POLICY_OID CREATED_DATE EFFECTIVE_DATE STATUS UPDATED_DATE
1234 06/14/2020 06/14/2010 active 06/14/2010
POLICY_RELATIONSHIP_OID POLICY_ACTOR POLICY_ACTOR_TYPE POLICY_OID
98765 John Primary User 1234
98766 Bill Secondary User 1234
98767 Mary Intermediate User 1234
If I try to persist the Policy Object 1234 and UPDATED_DATE changed to 06/15/2010 and the PolicyRelationship has data like below
POLICY_RELATIONSHIP_OID POLICY_ACTOR POLICY_ACTOR_TYPE POLICY_OID
null George Primary User 1234
Is there any possible way with hibernate, to delete the three rows which already exist in the PolicyRelation table and insert an new row with new Data.
Please let me know if my problem is still unclear.
My Environment:
Java 1.6, Hibernate 3.5, JBoss.