Hi Himadri,

I think I found the reason why it is working with my sample and not with your 
application.

In my sample, I ran the mapping tool and having annotation 
@ForeignKey(deleteAction=ForeignKeyAction.NULL) is generating an SQL statement
ALTER TABLE EntityA ADD FOREIGN KEY (EntityBId) REFERENCES EntityB (id) ON 
DELETE SET NULL DEFERRABLE

So I should say it is not openJPA but database is causing the columns to 
nullify.( the functionality that you are looking for)

In your application you probably might have added foreign key without the "on 
delete" clause.

So, it brings back to your initial question of, if the same thing is possible 
by openJPA ?

So far I think the way you are manually nullifying the columns at entity level 
is the easiest way I can think of.

May be someone with prior experience with it can comment.

I will continue my research to find if there is any other way.
I think, @ForeignKey(deleteAction=ForeignKeyAction.NULL) 
should actually be honored by openJPA and nullifying the foreignkey columns 
should be handled by openJPA itself.

One other thing I can think of is to have a custom implementation 
OrphanedKeyAction interface.
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_orphan

I have not tried this before but reading the documentation looks like it may be 
possible.

Regards,
Ravi.

-----Original Message-----
From: Ravi Palacherla 
Sent: Thursday, January 21, 2010 12:39 AM
To: [email protected]
Subject: Re: How to specifiy Cascase None for OneToMany


Hi,

Hmm... It worked for me on a standalone openJPA testcase against derby DB.

As you are running on WLS and against oracle DB, I created a testcase with
similar environment.

http://n2.nabble.com/file/n4432179/EJBTestCase.zip EJBTestCase.zip 

Please download the attached zip file. Modify build.xml,
build-properties.xml and META-INF\persistence.xml to reflect your local
environment.

Then run 
ant      ( this will create db tables , build EJB and deploy it on WLS)
ant test.remote  ( this will run the EJB which will remove the primary row
and insert new entitys)

After running the above testcase, I can clearly see that the foreignkey
column is nullified when I remove the primay row ( using em.remove())

Regards,
Ravi.
-- 
View this message in context: 
http://n2.nabble.com/How-to-specifiy-Cascase-None-for-OneToMany-tp4426059p4432179.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to