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 Sat, 20 Sep 2003 21:43:51 GMT
Hi Olli, 

I've implemented your fix in another way, but I hope it still works, please 
tell me if I'm right ;-)

Oleg

On Friday 19 September 2003 12:55, oliver.matz@ppi.de wrote:
> Hello Oleg,
>
> the appended change fixes the problem for me.
> Please have a look at it.
>
> I attach the File ReferencePrefetcher.java, I hope
> the attachment works this time.
>
>
> Olli
>
> > -----Original Message-----
> >
> > > -----Original Message-----
> > > From: oliver.matz@ppi.de [mailto:oliver.matz@ppi.de]
>
> [..]
>
> > I do the following:
> >
> > myPB.getObjectByIdentity(aId);
> >
> > for an XA-identity.  Remember that XA has a collection of XB
> > (1-n relation), and XB has a reference of type XC.
> > The A-instance identified by aId has one XB-instance,
> > which has a null-reference (i.e., a null foreign key) to XC.
> >
> > SELECT CLASS_NAME,PARENT_FK,CHILD_FK,ID FROM X_TABLE WHERE ID = '221'
> > SELECT A0.CLASS_NAME,A0.PARENT_FK,A0.CHILD_FK,A0.ID FROM X_TABLE A0
> >         WHERE ( A0.PARENT_FK =  '221' )
> >         AND  (A0.CLASS_NAME =  'org.apache.ojb.broker.XB' )
> > SELECT ID FROM XC_TABLE WHERE ID = ''
> >
> > The last statement is certainly not as bad as a full table scan,
> > but superflous, too.  It did not appear is rc4.
>
> Index: ReferencePrefetcher.java
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-ojb/src/java/org/apache/ojb/broker/accesslayer/Refe
>r encePrefetcher.java,v
> retrieving revision 1.9
> diff -c -r1.9 ReferencePrefetcher.java
> *** ReferencePrefetcher.java	18 Sep 2003 20:08:32 -0000	1.9
> --- ReferencePrefetcher.java	19 Sep 2003 12:52:16 -0000
> ***************
> *** 109,119 ****
>   		{
>   			owner = iter.next();
>   			fkValues = ord.getForeignKeyValues(owner,cld);
> !             id = new Identity(null, topLevelClass, fkValues);
> ! 			relatedObject = pb.getObjectByIdentity(id);
> ! 			field.set(owner, relatedObject);
>   		}
>   	}
>
>       /**
>        * Build the multiple queries for one relationship because of
> limitation of IN(...)
> --- 109,132 ----
>   		{
>   			owner = iter.next();
>   			fkValues = ord.getForeignKeyValues(owner,cld);
> !       if (!isNull(fkValues))
> !       {
> !         id = new Identity(null, topLevelClass, fkValues);
> !         relatedObject = pb.getObjectByIdentity(id);
> !         field.set(owner, relatedObject);
> !       }
>   		}
>   	}
> +
> +   private boolean isNull(Object[] arr)
> +   {
> +     for (int i = 0; i < arr.length; i++)
> +     {
> +       if (arr[i] != null)
> +         return false;
> +     }
> +     return true;
> +   }
>
>       /**
>        * Build the multiple queries for one relationship because of
> limitation of IN(...)


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