db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armin Waibel <ar...@code-au-lait.de>
Subject [BUG] Prefetch bug?
Date Fri, 12 Dec 2003 22:00:05 GMT
Hi all,

Andy Malakov reported me a *serious* bug in conjunction with

Seems that these method return different result for the same query.
I checked in a modified version of his test cases

first one pass, second fail. (metadata in repository_junit_reference.xml)

Below see his original post with detailed description of what is going 
on (attached p6spy output).

Needs to be fixed before rc5!!


-------- Original Message --------
Subject: 	Reference to base class Re: OJB
Date: 	Fri, 12 Dec 2003 11:14:30 -0500
From: 	Andy Malakov <andy@transdecisions.com>

Hello Armin,

Thanks for submitting that fix.

What troubles me is that I found some problem retrieving collections of
objects that have reference to extent. Problem exists in "CVS HEAD"
and didn't exist in RC4. /Very/ easy to reproduce.

Say, I have class BookShelf that has list of BookShelfItems. There are
several kinds of BookShelfItems: Books, DVDs, etc.

     *public class BookShelf {
         private int pk;
         private List /*of BookShelfItem*/ items;*
     *     ...*
     *public abstract class BookShelfItem {
         private int pk;
         private BookShelf shelf;*
     *    ...*
     *public class Book extends BookShelfItem {*
     *public class DVD extends BookShelfItem {*

Now if I create a bookshelf with one book and one DVD, I can load it via
getIteratorByQuery() without any problems:

*b.getIteratorByQuery(new QueryByCriteria (BookShelf.class, new Criteria

But when I try to use getCollectionByQuery(), I each bookshelf _only has
one item_ (!) [More precisely one kind of items in case of larger number
of items]

*b.getCollectionByQuery(new QueryByCriteria (BookShelf.class, new
Criteria ()));*

After some debugging I found what looks like a problem in

When CollectionPrefetcher.associateBatched(Collection owners, Collection
children) associates bookshelfs with items (at this moment I can see
that both collections contain valid number of items) it have problems
findinf foreign key values in child items.

CollectionPrefetcher, line178 (CVS):
*    for (Iterator it = children.iterator(); it.hasNext(); )
        relatedObject = it.next(); // child item
        fkValues = cds.getForeignKeyValues(relatedObject, cld);*

Problem is caused by the fact that *getForeignKeyValues* [in case of
reference to base class]  will search for foreign keys *only in class
descriptor of first concrete class* (!).

ObjectReferenceDescriptor, line 143 (CVS):

*     Class firstConcreteClass = (Class) extents.get(0);
      mif =

I have the above example as simple JUnit test case (attached). Let me
know  - I will be happy to provide any additional information.

I can also submit a bugreport into Scarab.

Thanks a lot,

View raw message