db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Nitz ...@ukr.net>
Subject Re: superflous, long queries in CVS HEAD (Batch retrieval)
Date Thu, 18 Sep 2003 23:13:42 GMT
Hi Oliver,

I hope I have fixed the bug, please update, run your test again and tell me if 
this is true!

Regards,
 Oleg

On Wednesday 17 September 2003 15:30, oliver.matz@ppi.de wrote:
> Hello again,
>
> I have written a test case that reproduces
> the problem.  Unfortunately, it needs
> two extra tables and three extra classes.
> That is because the OJB test classes all
> use basic types as foreign keys, and this
> issue occurs only with java wrapper types
> (such as java.lang.Integer).
>
> Below you find more information.
>
> How to proceed now?
> Do you agree that this is a bug?
> Shall I add this issue to scarab?
> (It is not reproducable with any release candidate).
> Shall I mail the test to anybody?
>
> Regards,
>   Olli
>
> > -----Original Message-----
> > From: oliver.matz@ppi.de [mailto:oliver.matz@ppi.de]
> > Sent: Wednesday, September 17, 2003 3:21 PM
> > To: ojb-dev@db.apache.org
> > Subject: superflous, long queries in CVS HEAD (Batch retrieval)
> >
> >
> > Hello,
> >
> > I noticed that several of my tests require more
> > SQL statements than in rc4,
> > among them ones without WHERE-clause, i.e.
> > 	select ... FROM A
> >
> > I debugged into it and saw that this seems
> > to be caused by null-references:
> >
> > Say I have a class A with a collection of B,
> > and B has a reference of type C.  Suppose
> > I load an instance of A and (by batch retrieval)
> > load the corresponding collection of B (say of size 1).
> > Suppose in that B instance the corresponding
> > foreignkey field (of type Long) is null.  When
> > the method
> >   buildPrefetchCriteriaSingleKey(ids, pkField)
> > is called for that field, the (only) fkVal will be null,
> > and hence fkValues will be empty.  Consequently, the
> > line 207
> > 	crit.addIn(pkField.getAttributeName(), fkValues);
> > is never reached.  This (potentially long running)
> > query on the table of C is then executed in
> >   RelationshipPrefetcherImpl.associateBatched()
>
> That's the test code:
>
>     myPB.clearCache();
>     myPB.beginTransaction();
>     XA a = (XA)myPB.getObjectByIdentity(aId);
>     myPB.commitTransaction();
>
> Appended you find the additions to repository_user.xml.
>
> Here is the output from p6spy. The third statement is superflous.
>
> SELECT CLASS_NAME,PARENT_FK,CHILD_FK,ID FROM X_TABLE WHERE ID = '581'
> SELECT A0.CLASS_NAME,A0.PARENT_FK,A0.CHILD_FK,A0.ID FROM X_TABLE A0 WHERE
>    ( A0.PARENT_FK =  '581' ) AND  (A0.CLASS_NAME =
> 'org.apache.ojb.broker.XB' )
> SELECT A0.ID FROM XC_TABLE A0
> SELECT ID FROM XC_TABLE WHERE ID = ''
>
> -----
> <class-descriptor
>   class="org.apache.ojb.broker.XA"
>   table="X_TABLE"
>
>   <field-descriptor
>      name="id"
>      column="ID"
>      jdbc-type="INTEGER"
>      primarykey="true"
>      autoincrement="true"
>   />
>   <field-descriptor
>      name="ojbConcreteClass"
>      column="CLASS_NAME"
>      jdbc-type="VARCHAR"
>   />
>   <collection-descriptor
>      name="someXBs"
>      element-class-ref="org.apache.ojb.broker.XB"
>
> collection-class="org.apache.ojb.broker.util.collections.ManageableArrayLis
>t "
>      auto-update="true"
>
>      <inverse-foreignkey field-ref="a_id"/>
>   </collection-descriptor>
>
> </class-descriptor>
>
> <class-descriptor
>   class="org.apache.ojb.broker.XB"
>   table="X_TABLE"
>
>   <field-descriptor
>     name="id"
>     column="ID"
>     jdbc-type="INTEGER"
>     primarykey="true"
>     autoincrement="true"
>  />
>   <field-descriptor
>     name="c_id"
>     column="CHILD_FK"
>     jdbc-type="INTEGER"
>   />
>   <field-descriptor
>     name="a_id"
>     column="PARENT_FK"
>     jdbc-type="INTEGER"
>   />
>   <field-descriptor
>      name="ojbConcreteClass"
>      column="CLASS_NAME"
>      jdbc-type="VARCHAR"
>   />
>   <reference-descriptor
>      name="c"
>      class-ref="org.apache.ojb.broker.XC"
>      proxy="false"
>
>     <foreignkey field-ref="c_id"/>
>   </reference-descriptor>
>  </class-descriptor>
>
>  <class-descriptor
>    class="org.apache.ojb.broker.XC"
>    table="XC_TABLE"
>
>   <field-descriptor
>     name="id"
>     column="ID"
>     jdbc-type="INTEGER"
>     primarykey="true"
>     autoincrement="true"
>   />
>  </class-descriptor>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org


---------------------------------------------------------------------
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