Thanks for the quick reply: The modified test case indeed succeeds.

I played a little with the code to find out which of the changes is the 
essential one. It turns out that assigning a group id different from 0 to 
the ProductGroup fixes the problem. The transaction demarcation without 
assigning a group id still reproduced the error.Somehow the group id 0 
seems to interfere with another test case, although I couldn't find one 
that also uses a group id = 0 without auto-increment set to true.

Anyway, I believe this kind of thing shouldn't hit us in a production 
application.

Thanks again,
Gerhard







"Armin Waibel" <[EMAIL PROTECTED]>
11.08.2003 11:00
Bitte antworten an "OJB Users List"

 
        An:     "OJB Users List" <[EMAIL PROTECTED]>
        Kopie: 
        Thema:  Re: Strange UnitTest Failure with DB2


hmm strange, I checked in a modified version
of this test case.
Add tx-demarcation for object operations
(this is necessary in non-managed environments).
Give it a try ;-)

regards,
Armin

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, August 11, 2003 10:24 AM
Subject: Strange UnitTest Failure with DB2


> Hi all,
>
> We are currently evaluating OJB for use with our DB2 databases. Trying
to
> run the JUnit tests we observe a rather strange behavior with the
testcase
>
org.apache.ojb.broker.OneToManyTest.testDeleteWithRemovalAwareCollection
():
>
> When running all tests (ant junit-no-compile), the testcase fails with
a
> failed assertion (expeced <1> but was <0>). However, when running just
> OneToManyTest alone, the tests succeeds.
>
> We tried to track the problem down by logging the SQL with P6Spy and
found
> that in the failure case, OJB for some reason creates a new entry in
> KATEGORIEN when it just should delete two ARTIKEL entries. It then
moves
> the ARTIKELs to this new KATEGORIEN entry (by changing the
Kategorie_Nr
> field) and then deletes the two ARTIKELs. The result is that there are
> zero ARTIKELS in the original KATEGORIEN entry (hence the testcase
> failure) and one remaining of three with the mysterious new KATEGORIEN
> entry. This does not happen when running OneToManyTest alone.
>
> I am appending the SQL logs below. The SQL statements are condensed
for
> better readability and I added the Java code lines that triggererd the
> SQL.
>
> If someone could help shed a light on this, I would be most grateful.
(The
> broker tests run fine when using HSQLDB).
>
> Gerhard Grosse
>
>
> System Info:
> JDK 1.3.1_08
> OJB 1.0RC4 (with otm classes removed to compile with 1.3)
> Client: Windows XP
> Server: DB2 7.2 Linux
>
> SQL Log of OneToManyTest.testDeleteWithRemovalAwareCollection() when
> running all tests:
>
>         ProductGroupWithRemovalAwareCollection pg = new
> ProductGroupWithRemovalAwareCollection();
>         pg.setGroupName("nice group");
>         Identity pgId = new Identity(pg, broker);
>         Article a = new Article();
>         a.setArticleName("a");
>         Article b = new Article();
>         b.setArticleName("b");
>         Article c = new Article();
>         c.setArticleName("c");
>         pg.add(a);
>         pg.add(b);
>         pg.add(c);
>         broker.store(pg);
>
> 1060348532390|0|1|statement|SELECT FROM Kategorien WHERE Kategorie_Nr
=
> '0'
> 1060348532390|0|1|statement|INSERT INTO Kategorien
> (Kategorie_Nr,KategorieName) VALUES ('0','nice group')
> 1060348532390|0|1|statement|SELECT FROM Artikel WHERE Artikel_Nr =
'88894'
>
> 1060348532390|0|1|statement|INSERT INTO Artikel VALUES
> ('88894','a','0','0','','0.0','0','0','0','0')
> 1060348532390|0|1|statement|SELECT FROM Artikel WHERE Artikel_Nr =
'88895'
>
> 1060348532390|0|1|statement|INSERT INTO Artikel VALUES
> ('88895','b','0','0','','0.0','0','0','0','0')
> 1060348532390|0|1|statement|SELECT FROM Artikel WHERE Artikel_Nr =
'88896'
>
> 1060348532406| |1|statement|INSERT INTO Artikel VALUES
> ('88896','c','0','0','','0.0','0','0','0','0')
>
>         broker.clearCache();
>         pg = (ProductGroupWithRemovalAwareCollection)
> broker.getObjectByIdentity(pgId);
>         assertEquals(3,pg.getAllArticles().size());
>
> 1060348535406|0|1|statement|SELECT FROM Kategorien WHERE Kategorie_Nr
=
> '0'
> 1060348535406|0|1|statement|SELECT FROM Artikel A0 WHERE
A0.Kategorie_Nr =
>  '0'
> 1060348535406|0|1|statement|SELECT FROM BOOKS A0 WHERE A0.Kategorie_Nr
=
> '0'
> 1060348535406|0|1|statement|SELECT FROM CDS A0 WHERE A0.Kategorie_Nr =
'0'
>
>
>         pg.getAllArticles().remove(c);
>         pg.getAllArticles().remove(0);
>         broker.store(pg);
>
> 1060348539406|0|1|statement|SELECT FROM Artikel WHERE Artikel_Nr =
'88894'
>
> 1060348539406|0|1|statement|SELECT FROM Kategorien WHERE Kategorie_Nr
=
> '0'
> 1060348539406|0|1|statement|SELECT FROM Artikel A0 WHERE
A0.Kategorie_Nr =
>  '25'  ORDER BY 4 DESC
> 1060348539406|0|1|statement|SELECT FROM BOOKS A0 WHERE A0.Kategorie_Nr
=
> '25'  ORDER BY 6 DESC
> 1060348539406|0|1|statement|SELECT FROM CDS A0 WHERE A0.Kategorie_Nr =
> '25'  ORDER BY 5 DESC
> 1060348539421| |1|statement|UPDATE Kategorien SET KategorieName='nice
> group' WHERE Kategorie_Nr = '0'
> 1060348539421|0|1|statement|SELECT FROM Artikel WHERE Artikel_Nr =
'88895'
>
> 1060348539421|0|1|statement|SELECT FROM Kategorien WHERE Kategorie_Nr
=
> '25'
> 1060348539421|0|1|statement|INSERT INTO Kategorien VALUES ('25','nice
> group','')
> 1060348539421|0|1|statement|UPDATE Artikel SET Kategorie_Nr='25' WHERE
> Artikel_Nr = '88895'
> 1060348539421|0|1|statement|SELECT FROM Artikel WHERE Artikel_Nr =
'88896'
>
> 1060348539421|0|1|statement|UPDATE Kategorien SET KategorieName='nice
> group',Beschreibung='' WHERE Kategorie_Nr = '25'
> 1060348539437|0|1|statement|UPDATE Artikel SET Kategorie_Nr='25' WHERE
> Artikel_Nr = '88896'
> 1060348539437|0|1|statement|DELETE FROM Artikel WHERE Artikel_Nr =
'88896'
>
> 1060348539437|0|1|statement|DELETE FROM Artikel WHERE Artikel_Nr =
'88894'
>
>
>         broker.clearCache();
>         pg = (ProductGroupWithRemovalAwareCollection)
> broker.getObjectByIdentity(pgId);
>         assertEquals(1,pg.getAllArticles().size());    // failure!
>
> 1060348544437|0|1|statement|SELECT FROM Kategorien WHERE Kategorie_Nr
=
> '0'
> 1060348544437|0|1|statement|SELECT FROM Artikel A0 WHERE
A0.Kategorie_Nr =
>  '0'
> 1060348544437|0|1|statement|SELECT FROM BOOKS A0 WHERE A0.Kategorie_Nr
=
> '0'
> 1060348544437|0|1|statement|SELECT FROM CDS A0 WHERE A0.Kategorie_Nr =
'0'
>
>
> ===========================
> SQL Log of OneToManyTest.testDeleteWithRemovalAwareCollection() when
> running all tests:
>
>         ProductGroupWithRemovalAwareCollection pg = new
> ProductGroupWithRemovalAwareCollection();
>         pg.setGroupName("nice group");
>         Identity pgId = new Identity(pg, broker);
>         Article a = new Article();
>         a.setArticleName("a");
>         Article b = new Article();
>         b.setArticleName("b");
>         Article c = new Article();
>         c.setArticleName("c");
>         pg.add(a);
>         pg.add(b);
>         pg.add(c);
>         broker.store(pg);
>
> 1060350474953|0|0|statement|SELECT FROM Kategorien WHERE Kategorie_Nr
=
> '0'
> 1060350474968| |0|statement|INSERT INTO Kategorien
> (Kategorie_Nr,KategorieName) VALUES ('0','nice group')
> 1060350475031|0|1|statement|SELECT
> A0.MAX_KEY,A0.TABLENAME,A0.GRAB_SIZE,A0.VERSION,A0.FIELDNAME FROM
> OJB_HL_SEQ A0 WHERE (A0.TABLENAME LIKE  ? ) AND A0.FIELDNAME LIKE  ?
> |SELECT A0.MAX_KEY,A0.TABLENAME,A0.GRAB_SIZE,A0.VERSION,A0.FIELDNAME
FROM
> OJB_HL_SEQ A0 WHERE (A0.TABLENAME LIKE  'SEQ_Artikel' ) AND
A0.FIELDNAME
> LIKE  'Artikel_Nr'
>
> 1060350475046|0|0|statement||SELECT MAX(Artikel_Nr) FROM Artikel
> 1060350475046|0|0|statement||SELECT MAX(Artikel_Nr) FROM BOOKS
> 1060350475046|0|0|statement||SELECT MAX(Artikel_Nr) FROM CDS
> 1060350475062|0|0|statement||SELECT MAX(Artikel_Nr) FROM BOOKS
> 1060350475062|0|0|statement||SELECT MAX(Artikel_Nr) FROM CDS
> 1060350475062|0|1|statement|SELECT
> MAX_KEY,TABLENAME,GRAB_SIZE,VERSION,FIELDNAME FROM OJB_HL_SEQ WHERE
> TABLENAME = ?  AND FIELDNAME = ? |SELECT
> MAX_KEY,TABLENAME,GRAB_SIZE,VERSION,FIELDNAME FROM OJB_HL_SEQ WHERE
> TABLENAME = 'SEQ_Artikel'  AND FIELDNAME = 'Artikel_Nr'
> 1060350475062|0|1|statement|INSERT INTO OJB_HL_SEQ
> (TABLENAME,FIELDNAME,MAX_KEY,GRAB_SIZE,VERSION) VALUES (?,?,?,?,?)
|INSERT
> INTO OJB_HL_SEQ (TABLENAME,FIELDNAME,MAX_KEY,GRAB_SIZE,VERSION) VALUES
> ('SEQ_Artikel','Artikel_Nr','222','20','1')
> 1060350475062|0|1|commit||
>
> 1060350475078| |0|statement|SELECT FROM Artikel WHERE Artikel_Nr =
'203'
> 1060350475078|0|0|statement|INSERT INTO Artikel VALUES
> ('203','a','0','0','','0.0','0','0','0','0')
> 1060350475078|0|0|statement|SELECT FROM Artikel WHERE Artikel_Nr =
'204'
> 1060350475093|0|0|statement|INSERT INTO Artikel VALUES
> ('204','b','0','0','','0.0','0','0','0','0')
> 1060350475093|0|0|statement|SELECT FROM Artikel WHERE Artikel_Nr =
'205'
> 1060350475093|0|0|statement|INSERT INTO Artikel VALUES
> ('205','c','0','0','','0.0','0','0','0','0')
>
>         broker.clearCache();
>         pg = (ProductGroupWithRemovalAwareCollection)
> broker.getObjectByIdentity(pgId);
>         assertEquals(3,pg.getAllArticles().size());
>
> 1060350478093|0|0|statement|SELECT Kategorien WHERE Kategorie_Nr = '0'
> 1060350478109|0|0|statement|SELECT FROM Artikel A0 WHERE
A0.Kategorie_Nr =
>  '0'
> 1060350478109|0|0|statement|SELECT FROM BOOKS A0 WHERE A0.Kategorie_Nr
=
> '0'
> 1060350478125|0|0|statement|SELECT FROM CDS A0 WHERE A0.Kategorie_Nr =
'0'
>
>
>         pg.getAllArticles().remove(c);
>         pg.getAllArticles().remove(0);
>         broker.store(pg);
>
> 1060350482125|0|0|statement|SELECT FROM Artikel WHERE Artikel_Nr =
'203'
> 1060350482125|0|0|statement|UPDATE Kategorien SET KategorieName='nice
> group' WHERE Kategorie_Nr = '0'
> 1060350482125|0|0|statement|SELECT FROM Artikel WHERE Artikel_Nr =
'204'
> 1060350482140|0|0|statement|UPDATE Artikel SET Kategorie_Nr='0' WHERE
> Artikel_Nr = '204'
> 1060350482140|0|0|statement|SELECT FROM Artikel WHERE Artikel_Nr =
'205'
> 1060350482140|0|0|statement|UPDATE Artikel SET Kategorie_Nr='0' WHERE
> Artikel_Nr = '205'
> 1060350482156| |0|statement|DELETE FROM Artikel WHERE Artikel_Nr =
'205'
> 1060350482156|0|0|statement|DELETE FROM Artikel WHERE Artikel_Nr =
'203'
>
>         broker.clearCache();
>         pg = (ProductGroupWithRemovalAwareCollection)
> broker.getObjectByIdentity(pgId);
>         assertEquals(1,pg.getAllArticles().size());    // ok
>
> 1060350487156|0|0|statement|SELECT FROM Kategorien WHERE Kategorie_Nr
=
> '0'
> 1060350487156|0|0|statement|SELECT FROM Artikel A0 WHERE
A0.Kategorie_Nr =
>  '0'
> 1060350487156|0|0|statement|SELECT FROM BOOKS A0 WHERE A0.Kategorie_Nr
=
> '0'
> 1060350487156|0|0|statement|SELECT FROM CDS A0 WHERE A0.Kategorie_Nr =
'0'
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to