Hi Armin, On 3/27/06, Armin Waibel <[EMAIL PROTECTED]> wrote: > > Hi Jean-Yves, > > Jean-Yves Sironneau wrote: > > Hello, > > > > Yes another question again. > > > > I have a class Area that is referencing a class Point, and Area has a > > foreign key constraint on Point. > > I'am using ODMG, and i would like OJB to delete the Point when i delete > the > > Area. What happens is that when i commit a > > transaction for removing an Area, OJB is trying to remove the Point but > of > > course it can't because the foreing key constraint is > > violated as the Area is still referencing the point. So i suppose the > Area > > should be removed first for this to work. Do you think it can > > be a bug ? Do i have to manually unreference the point somewhere ? > > > > Do you use auto-delete="object" in Area 1:1 reference-descriptor to Point? > > http://db.apache.org/ojb/docu/guides/odmg-guide.html#Specific+Metadata+Settings
Yes If you have problems with the order of persistent objects you can > > A. disable ordering and set object order by hand (first delete Area, > then Point) > > http://db.apache.org/ojb/docu/guides/odmg-guide.html#Disable+OJB%27s+object+ordering%2C+determine+object+order+%22by+hand%22 Yes, but the problem is that i do not explicitely call a delete method on this object, I remove an object that is referencing an Area, and the Area is referencing the Point, this is a "cascade" delete. B. use a workaround to specify the database FK. Simply set a custom > property 'constraint' in reference-descriptor of Area. > <attribute attribute-name="constraint" attribute-value="true"/> > > http://db.apache.org/ojb/docu/guides/odmg-guide.html#Foreign+Keys+Constraints+and+ODMG-api > > If set OJB's ordering try to take care of the database constraint. I tried but it did not work, here is an extract of the sql statements generated by OJB 1143500067952|0|1|statement||SELECT A0.id,A0.documentBaseId,A0.firstName, A0.lastName,A0.email,A0.url FROM Person A0 WHERE A0.documentBaseId='27WXcUHNXRZ36EkQnYIQqmHsbqPqX9k9cnOoAyPgbf65g2Cqql' 1143500068124|161|0|statement||DELETE FROM Point WHERE id = 'OmEWtzi9bM9etJISTKWWjKaUlmUTopM6c8W5xGQUN8yKp7HQFs' 1143500068206|1|0|rollback|| What I do not get is that the database foreign key check is deferrable (postgres), so this statement should be ok if followed by the deletion of the Area, but i have to look more precisely at the meaning of deferred in postgres. Anyway if it does not work i will try to reverse the relation and it should work. Thank you. Jean-Yves > Thank you. > > > > Jean-Yves > > > > P.S.: > > > > I'am not a foreign key constraint expert, but i tried to use > deferrable=true > > for this constraint and it does not work neither. > > strange! I would expect that in this case delete ordering is irrelevant. > > regards, > Armin > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >