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.
My Environment:
Java 1.6, Hibernate 3.5, JBoss.
|