db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Nitz ...@ukr.net>
Subject [proposal] Proxy prefetching
Date Sun, 14 Sep 2003 21:55:03 GMT
Hi All,

I am going to implement the feature described below and propose to turn it on  
by default or even always. I'd like to know your opinions on this: should it 
be configurable or not and if yes, what should be the default behavior.

Now the idea. You all know such classes as Article and ProductGroup, I will 
use them as example. Assume that we load the collection of Articles by some 
query. They all refer to ProductGroups. Assume that we do something like 
this:

    Collection col = pb.getCollectionByQuery(query);
    for (Iterator it = col.iterator(); it.hasNext(); )
    {
        Article article = (Article) it.next();
        doSomething(article.getProductGroup().getGroupName());
    }

If ProductGroup class wasn't describes with 
   proxy="org.apache.ojb.broker.ProductGroupProxy"
in repository.xml, then all the referred ProductGroups would be loaded by one 
query due to the recently added batch retrieval feature. But with proxy each 
ProductGroup instance would be loaded by separate query. I propose to load 
them all by one query: if user called getProductGroup().getGroupName() for 
the first article in the collection, most probably user will call this for 
all articles, and I propose to prefetch them. If user don't use 
ProductGroup's fields, like this

    Collection col = pb.getCollectionByQuery(query);
    for (Iterator it = col.iterator(); it.hasNext(); )
    {
        Article article = (Article) it.next();
        doSomething(article.getArticleName());
    }

then no ProductGroups will be loaded at all, as previously.
Similarly for CollectionProxies.
So, what do you think?

Regards,
 Oleg

P.S. Prefetching in JBoss CMP 2.0 works in a similar way.



   	  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message