You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Jakob Braeuchi <jb...@gmx.ch> on 2002/12/04 22:07:47 UTC

test cases fail with foreign keys in hsqldb

hi all,

thanks to armin i found that torque does not create the foreign keys defined
in -schema.xml when using hsqldb. thanks to these lacking foreign keys our
test cases pass witout errors... when enabling referential integrity some
test cases fail:

java.sql.SQLException: Integrity constraint violation: TASK_FK_1 table: TASK
in statement [DELETE FROM PERSON_PROJECT WHERE (PROJECT_ID = 1)]
at org.hsqldb.Trace.getError(Unknown Source)
...
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.deleteMtoNImplementor(P
ersistenceBrokerImpl.java:856)
..
at org.apache.ojb.broker.MtoNMapping.testInsertion(MtoNMapping.java:191)

....

java.sql.SQLException: Integrity constraint violation: TASK_FK_1 table: TASK
in statement [DELETE FROM PERSON_PROJECT WHERE (PROJECT_ID = 2)]
..
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.deleteMtoNImplementor(P
ersistenceBrokerImpl.java:856)
..
at org.apache.ojb.broker.MtoNMapping.testInsertion(MtoNMapping.java:191)

the attached .vm files are the modifications i made to enable referential
integrity for hsqldb in torque.
replace those file found in torque.jar sql\base\hypersonic with the ones
attached. i already sent these files to martin poeschl of torque.

hth
jakob

Re: test cases fail with foreign keys in hsqldb

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi thomas,

i also fixed the BIDIR problem in ODMG.

jakob
----- Original Message -----
From: "Thomas Mahler" <th...@apache.org>
To: "OJB Developers List" <oj...@jakarta.apache.org>
Sent: Friday, December 13, 2002 7:21 PM
Subject: Re: test cases fail with foreign keys in hsqldb


> Thanks! Now PB is clear again!
>
> Jakob Braeuchi wrote:
> > hi thomas,
> >
> > i fixed the testdata, no more integrity violations in PB testcases.
still
> > have to check all ODMG tests.
> >
> > jakob
> >
> > ----- Original Message -----
> > From: "Thomas Mahler" <th...@apache.org>
> > To: "OJB Developers List" <oj...@jakarta.apache.org>
> > Sent: Tuesday, December 10, 2002 9:54 PM
> > Subject: Re: test cases fail with foreign keys in hsqldb
> >
> >
> >
> >>Hi,
> >>
> >>I've just checked your latest changes from CVS.
> >>I still got 3 errors in the PB testcases:
> >>testInsertDeleteNoAutoSequence
> >>testInsertDeleteAutoSequenceClearCache
> >>testInsertDeleteAutoSequence
> >>
> >>AFAICS they are not directly related to m:n stuff, but it seems to be a
> >>problem with the new enforced integrity constrains on the test data?
> >>
> >>Any ideas?
> >>cheers,
> >>Thomas
> >>
> >>
> >>jbraeuchi@gmx.ch wrote:
> >>
> >>>hi oleg,
> >>>
> >>>the fixes are now in the repository. i also fixed a problem with
> >>>CollectionProxy size() using m:n queries (always returned 0), so all
the
> >>
> > MNMapping
> >
> >>>testcases pass.
> >>>i still have a problem with the BIDIR testcase whisch is imo a circular
> >>>reference.
> >>>
> >>>jakob
> >>>
> >>>
> >>>
> >>>>Hi Jakob,
> >>>>
> >>>>On Sunday 08 December 2002 10:59, Jakob Braeuchi wrote:
> >>>>
> >>>>
> >>>>>when deleting the Person Roles and Tasks were not deleted because of
> >>>>>auto-delete = false.
> >>>>>the rows of the indirection-table are correctly deleted but Task
still
> >>>>>references these rows, so we get an integrity violation !
> >>>>>
> >>>>>after changeing auto-delete = true for Roles and Task the situation l
> >>>>
> >>>>ooks
> >>>>
> >>>>
> >>>>>better.
> >>>>
> >>>>Reasonable solution.
> >>>>
> >>>>
> >>>>
> >>>>>i'm still working on improving deleteMtoNImplementors when
> >>>>>storingCollections. imo it's useless (and may violate integrity) to
del
> >>>>
> >>>>ete
> >>>>
> >>>>
> >>>>>all rows in indirection-table and later reinsert them, when nothing
has
> >>>>>changed there...
> >>>>
> >>>>Absolutely agree with you.
> >>>>
> >>>>Oleg
> >>>>
> >>>>
> >>>>
> >>>>--
> >>>>To unsubscribe, e-mail:
> >>>
> > <ma...@jakarta.apache.org>
> >
> >>>>For additional commands, e-mail:
> >>>
> > <ma...@jakarta.apache.org>
> >
> >>
> >>
> >>--
> >>To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> >>For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >>
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> >
> >
> >
>
>
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>


Re: test cases fail with foreign keys in hsqldb

Posted by Thomas Mahler <th...@apache.org>.
Thanks! Now PB is clear again!

Jakob Braeuchi wrote:
> hi thomas,
> 
> i fixed the testdata, no more integrity violations in PB testcases. still
> have to check all ODMG tests.
> 
> jakob
> 
> ----- Original Message -----
> From: "Thomas Mahler" <th...@apache.org>
> To: "OJB Developers List" <oj...@jakarta.apache.org>
> Sent: Tuesday, December 10, 2002 9:54 PM
> Subject: Re: test cases fail with foreign keys in hsqldb
> 
> 
> 
>>Hi,
>>
>>I've just checked your latest changes from CVS.
>>I still got 3 errors in the PB testcases:
>>testInsertDeleteNoAutoSequence
>>testInsertDeleteAutoSequenceClearCache
>>testInsertDeleteAutoSequence
>>
>>AFAICS they are not directly related to m:n stuff, but it seems to be a
>>problem with the new enforced integrity constrains on the test data?
>>
>>Any ideas?
>>cheers,
>>Thomas
>>
>>
>>jbraeuchi@gmx.ch wrote:
>>
>>>hi oleg,
>>>
>>>the fixes are now in the repository. i also fixed a problem with
>>>CollectionProxy size() using m:n queries (always returned 0), so all the
>>
> MNMapping
> 
>>>testcases pass.
>>>i still have a problem with the BIDIR testcase whisch is imo a circular
>>>reference.
>>>
>>>jakob
>>>
>>>
>>>
>>>>Hi Jakob,
>>>>
>>>>On Sunday 08 December 2002 10:59, Jakob Braeuchi wrote:
>>>>
>>>>
>>>>>when deleting the Person Roles and Tasks were not deleted because of
>>>>>auto-delete = false.
>>>>>the rows of the indirection-table are correctly deleted but Task still
>>>>>references these rows, so we get an integrity violation !
>>>>>
>>>>>after changeing auto-delete = true for Roles and Task the situation l
>>>>
>>>>ooks
>>>>
>>>>
>>>>>better.
>>>>
>>>>Reasonable solution.
>>>>
>>>>
>>>>
>>>>>i'm still working on improving deleteMtoNImplementors when
>>>>>storingCollections. imo it's useless (and may violate integrity) to del
>>>>
>>>>ete
>>>>
>>>>
>>>>>all rows in indirection-table and later reinsert them, when nothing has
>>>>>changed there...
>>>>
>>>>Absolutely agree with you.
>>>>
>>>>Oleg
>>>>
>>>>
>>>>
>>>>--
>>>>To unsubscribe, e-mail:
>>>
> <ma...@jakarta.apache.org>
> 
>>>>For additional commands, e-mail:
>>>
> <ma...@jakarta.apache.org>
> 
>>
>>
>>--
>>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>>For additional commands, e-mail: <ma...@jakarta.apache.org>
>>
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> 
> 




Re: test cases fail with foreign keys in hsqldb

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi thomas,

i fixed the testdata, no more integrity violations in PB testcases. still
have to check all ODMG tests.

jakob

----- Original Message -----
From: "Thomas Mahler" <th...@apache.org>
To: "OJB Developers List" <oj...@jakarta.apache.org>
Sent: Tuesday, December 10, 2002 9:54 PM
Subject: Re: test cases fail with foreign keys in hsqldb


> Hi,
>
> I've just checked your latest changes from CVS.
> I still got 3 errors in the PB testcases:
> testInsertDeleteNoAutoSequence
> testInsertDeleteAutoSequenceClearCache
> testInsertDeleteAutoSequence
>
> AFAICS they are not directly related to m:n stuff, but it seems to be a
> problem with the new enforced integrity constrains on the test data?
>
> Any ideas?
> cheers,
> Thomas
>
>
> jbraeuchi@gmx.ch wrote:
> > hi oleg,
> >
> > the fixes are now in the repository. i also fixed a problem with
> > CollectionProxy size() using m:n queries (always returned 0), so all the
MNMapping
> > testcases pass.
> > i still have a problem with the BIDIR testcase whisch is imo a circular
> > reference.
> >
> > jakob
> >
> >
> >>Hi Jakob,
> >>
> >>On Sunday 08 December 2002 10:59, Jakob Braeuchi wrote:
> >>
> >>>when deleting the Person Roles and Tasks were not deleted because of
> >>>auto-delete = false.
> >>>the rows of the indirection-table are correctly deleted but Task still
> >>>references these rows, so we get an integrity violation !
> >>>
> >>>after changeing auto-delete = true for Roles and Task the situation l
> >>
> >>ooks
> >>
> >>>better.
> >>
> >>Reasonable solution.
> >>
> >>
> >>>i'm still working on improving deleteMtoNImplementors when
> >>>storingCollections. imo it's useless (and may violate integrity) to del
> >>
> >>ete
> >>
> >>>all rows in indirection-table and later reinsert them, when nothing has
> >>>changed there...
> >>
> >>Absolutely agree with you.
> >>
> >>Oleg
> >>
> >>
> >>
> >>--
> >>To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> >>For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >>
> >
>
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>


Re: test cases fail with foreign keys in hsqldb

Posted by Thomas Mahler <th...@apache.org>.
Hi,

I've just checked your latest changes from CVS.
I still got 3 errors in the PB testcases:
testInsertDeleteNoAutoSequence
testInsertDeleteAutoSequenceClearCache
testInsertDeleteAutoSequence

AFAICS they are not directly related to m:n stuff, but it seems to be a 
problem with the new enforced integrity constrains on the test data?

Any ideas?
cheers,
Thomas


jbraeuchi@gmx.ch wrote:
> hi oleg,
> 
> the fixes are now in the repository. i also fixed a problem with
> CollectionProxy size() using m:n queries (always returned 0), so all the MNMapping
> testcases pass.
> i still have a problem with the BIDIR testcase whisch is imo a circular
> reference.
> 
> jakob
> 
> 
>>Hi Jakob,
>>
>>On Sunday 08 December 2002 10:59, Jakob Braeuchi wrote:
>>
>>>when deleting the Person Roles and Tasks were not deleted because of
>>>auto-delete = false.
>>>the rows of the indirection-table are correctly deleted but Task still
>>>references these rows, so we get an integrity violation !
>>>
>>>after changeing auto-delete = true for Roles and Task the situation l
>>
>>ooks
>>
>>>better.
>>
>>Reasonable solution.
>>
>>
>>>i'm still working on improving deleteMtoNImplementors when
>>>storingCollections. imo it's useless (and may violate integrity) to del
>>
>>ete
>>
>>>all rows in indirection-table and later reinsert them, when nothing has
>>>changed there...
>>
>>Absolutely agree with you.
>>
>>Oleg
>>
>>
>>
>>--
>>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>>For additional commands, e-mail: <ma...@jakarta.apache.org>
>>
> 



Re: test cases fail with foreign keys in hsqldb

Posted by jb...@gmx.ch.
hi oleg,

the fixes are now in the repository. i also fixed a problem with
CollectionProxy size() using m:n queries (always returned 0), so all the MNMapping
testcases pass.
i still have a problem with the BIDIR testcase whisch is imo a circular
reference.

jakob

> Hi Jakob,
> 
> On Sunday 08 December 2002 10:59, Jakob Braeuchi wrote:
> >
> > when deleting the Person Roles and Tasks were not deleted because of
> > auto-delete = false.
> > the rows of the indirection-table are correctly deleted but Task still
> > references these rows, so we get an integrity violation !
> >
> > after changeing auto-delete = true for Roles and Task the situation l
> ooks
> > better.
> Reasonable solution.
> 
> > i'm still working on improving deleteMtoNImplementors when
> > storingCollections. imo it's useless (and may violate integrity) to del
> ete
> > all rows in indirection-table and later reinsert them, when nothing has
> > changed there...
> Absolutely agree with you.
> 
> Oleg
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 

-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!


Re: test cases fail with foreign keys in hsqldb

Posted by Oleg Nitz <on...@ukr.net>.
Hi Jakob,

On Sunday 08 December 2002 10:59, Jakob Braeuchi wrote:
>
> when deleting the Person Roles and Tasks were not deleted because of
> auto-delete = false.
> the rows of the indirection-table are correctly deleted but Task still
> references these rows, so we get an integrity violation !
>
> after changeing auto-delete = true for Roles and Task the situation looks
> better.
Reasonable solution.

> i'm still working on improving deleteMtoNImplementors when
> storingCollections. imo it's useless (and may violate integrity) to delete
> all rows in indirection-table and later reinsert them, when nothing has
> changed there...
Absolutely agree with you.

Oleg



Re: test cases fail with foreign keys in hsqldb

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi oleg,

after some time of digging into storeCollections of PersistenceBrokerImpl i
found that deleteMtoNImplementor is not the only problem.
some relationship definitions in repository_junit.xml are simply wrong:

Person 1-n Role 1-n Task
Person n-n Project

when a Person is deleted the associated Roles must also die (auto-delete =
true), the same is true for Tasks. the problem we had is caused by the
following situation:

when deleting the Person Roles and Tasks were not deleted because of
auto-delete = false.
the rows of the indirection-table are correctly deleted but Task still
references these rows, so we get an integrity violation !

after changeing auto-delete = true for Roles and Task the situation looks
better.

i'm still working on improving deleteMtoNImplementors when
storingCollections. imo it's useless (and may violate integrity) to delete
all rows in indirection-table and later reinsert them, when nothing has
changed there...

jakob


----- Original Message -----
From: "Oleg Nitz" <on...@ukr.net>
To: "OJB Developers List" <oj...@jakarta.apache.org>
Sent: Friday, December 06, 2002 6:23 AM
Subject: Re: test cases fail with foreign keys in hsqldb


Hi Jakob,

On Wednesday 04 December 2002 21:18, Jakob Braeuchi wrote:
> the problem with referential integrity is caused by the deletion of all
m:n
> implemenors when storing m:n relationships:
FYI: there are also several referential integrity errors in ODMG test with
1:1 bidirectional references, when one of objects is deleted.

Oleg



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: test cases fail with foreign keys in hsqldb

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi oleg,

the problem with 1:1 bidirectional references is not easy tio solve, because
A references B and B references A, so whichever i delete first the result is
an integrity violation.

any ideas ?

jakob

----- Original Message -----
From: "Oleg Nitz" <on...@ukr.net>
To: "OJB Developers List" <oj...@jakarta.apache.org>
Sent: Friday, December 06, 2002 6:23 AM
Subject: Re: test cases fail with foreign keys in hsqldb


Hi Jakob,

On Wednesday 04 December 2002 21:18, Jakob Braeuchi wrote:
> the problem with referential integrity is caused by the deletion of all
m:n
> implemenors when storing m:n relationships:
FYI: there are also several referential integrity errors in ODMG test with
1:1 bidirectional references, when one of objects is deleted.

Oleg



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: test cases fail with foreign keys in hsqldb

Posted by Oleg Nitz <on...@ukr.net>.
Hi Jakob,

On Wednesday 04 December 2002 21:18, Jakob Braeuchi wrote:
> the problem with referential integrity is caused by the deletion of all m:n
> implemenors when storing m:n relationships:
FYI: there are also several referential integrity errors in ODMG test with 
1:1 bidirectional references, when one of objects is deleted.

Oleg



Re: test cases fail with foreign keys in hsqldb

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi all,

the problem with referential integrity is caused by the deletion of all m:n
implemenors when storing m:n relationships:

private void storeCollections(Object obj, Vector vecCds, Map markedForStore)
throws PersistenceBrokerException
{
// get all members of obj that are collections and store all their elements
Iterator i = vecCds.iterator();
while (i.hasNext())
{
CollectionDescriptor cds = (CollectionDescriptor) i.next();
Object col = cds.getPersistentField().get(obj);
if (cds.isMtoNRelation())
{
/* LEANDRO
* Clear all MtoN implementors.
* All new MtoN implementors are going to be added bellow
*/
//logger.info("STORE COLLECTIONS: deleting all MtoN implementors for field
"+cds.getPersistentField().getName());
deleteMtoNImplementor(cds, obj);
}
if (col != null)
{

any ideas ?

jakob

----- Original Message -----
From: "Jakob Braeuchi" <jb...@gmx.ch>
To: "OJB Developers List" <oj...@jakarta.apache.org>
Cc: "OJB Users List" <oj...@jakarta.apache.org>
Sent: Wednesday, December 04, 2002 10:07 PM
Subject: test cases fail with foreign keys in hsqldb


> hi all,
>
> thanks to armin i found that torque does not create the foreign keys
defined
> in -schema.xml when using hsqldb. thanks to these lacking foreign keys our
> test cases pass witout errors... when enabling referential integrity some
> test cases fail:
>
> java.sql.SQLException: Integrity constraint violation: TASK_FK_1 table:
TASK
> in statement [DELETE FROM PERSON_PROJECT WHERE (PROJECT_ID = 1)]
> at org.hsqldb.Trace.getError(Unknown Source)
> ...
>
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.deleteMtoNImplementor(P
> ersistenceBrokerImpl.java:856)
> ..
> at org.apache.ojb.broker.MtoNMapping.testInsertion(MtoNMapping.java:191)
>
> ....
>
> java.sql.SQLException: Integrity constraint violation: TASK_FK_1 table:
TASK
> in statement [DELETE FROM PERSON_PROJECT WHERE (PROJECT_ID = 2)]
> ..
>
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.deleteMtoNImplementor(P
> ersistenceBrokerImpl.java:856)
> ..
> at org.apache.ojb.broker.MtoNMapping.testInsertion(MtoNMapping.java:191)
>
> the attached .vm files are the modifications i made to enable referential
> integrity for hsqldb in torque.
> replace those file found in torque.jar sql\base\hypersonic with the ones
> attached. i already sent these files to martin poeschl of torque.
>
> hth
> jakob
>


----------------------------------------------------------------------------
----


> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: test cases fail with foreign keys in hsqldb

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi all,

the problem with referential integrity is caused by the deletion of all m:n
implemenors when storing m:n relationships:

private void storeCollections(Object obj, Vector vecCds, Map markedForStore)
throws PersistenceBrokerException
{
// get all members of obj that are collections and store all their elements
Iterator i = vecCds.iterator();
while (i.hasNext())
{
CollectionDescriptor cds = (CollectionDescriptor) i.next();
Object col = cds.getPersistentField().get(obj);
if (cds.isMtoNRelation())
{
/* LEANDRO
* Clear all MtoN implementors.
* All new MtoN implementors are going to be added bellow
*/
//logger.info("STORE COLLECTIONS: deleting all MtoN implementors for field
"+cds.getPersistentField().getName());
deleteMtoNImplementor(cds, obj);
}
if (col != null)
{

any ideas ?

jakob

----- Original Message -----
From: "Jakob Braeuchi" <jb...@gmx.ch>
To: "OJB Developers List" <oj...@jakarta.apache.org>
Cc: "OJB Users List" <oj...@jakarta.apache.org>
Sent: Wednesday, December 04, 2002 10:07 PM
Subject: test cases fail with foreign keys in hsqldb


> hi all,
>
> thanks to armin i found that torque does not create the foreign keys
defined
> in -schema.xml when using hsqldb. thanks to these lacking foreign keys our
> test cases pass witout errors... when enabling referential integrity some
> test cases fail:
>
> java.sql.SQLException: Integrity constraint violation: TASK_FK_1 table:
TASK
> in statement [DELETE FROM PERSON_PROJECT WHERE (PROJECT_ID = 1)]
> at org.hsqldb.Trace.getError(Unknown Source)
> ...
>
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.deleteMtoNImplementor(P
> ersistenceBrokerImpl.java:856)
> ..
> at org.apache.ojb.broker.MtoNMapping.testInsertion(MtoNMapping.java:191)
>
> ....
>
> java.sql.SQLException: Integrity constraint violation: TASK_FK_1 table:
TASK
> in statement [DELETE FROM PERSON_PROJECT WHERE (PROJECT_ID = 2)]
> ..
>
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.deleteMtoNImplementor(P
> ersistenceBrokerImpl.java:856)
> ..
> at org.apache.ojb.broker.MtoNMapping.testInsertion(MtoNMapping.java:191)
>
> the attached .vm files are the modifications i made to enable referential
> integrity for hsqldb in torque.
> replace those file found in torque.jar sql\base\hypersonic with the ones
> attached. i already sent these files to martin poeschl of torque.
>
> hth
> jakob
>



> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>