-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Delete child table records during the update of parent
PostPosted: Tue Jun 15, 2010 10:05 am 
Newbie

Joined: Tue Mar 23, 2010 5:32 pm
Posts: 8
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.