I saw the addPrefetchedRelationship but I don't know how use it.  Do I have
to set something up in the repository.xml?  What does the word "konti"
relate to?  Is there any documentation on this?

Thanks in advance,
Graham

-----Original Message-----
From: Jakob Braeuchi [mailto:jbraeuchi@;gmx.ch]
Sent: October 17, 2002 2:15 PM
To: OJB Users List
Subject: Re: Nested Selects


hi graham,

when you do nested select the way you describe then you'll end up with n + 1
sql statements.
ojb provides an optimized way to reduce the number of sql select to 2. this
is done by prefetched relationships.

suppose you have persons having n adresses. when you define the adress
relationship as prefetched, all adresses for all persons are retrieved in
ONE call.

  Query query;
  Criteria crit;

  crit = new Criteria();
  crit.addOrderByDescending("id");
  crit.addOrderByAscending("geburtsDatum");
  crit.addPrefetchedRelationship("konti");
  query = new QueryByCriteria(Person.class, crit);
  broker.getCollectionByQuery(query);

hth
jakob

----- Original Message -----
From: "Graham Lounder" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Thursday, October 17, 2002 1:36 PM
Subject: Nested Selects


> Hey All,
>
> Is it possible to use nested selects?  What is the best approach to do
this?
> In my last project I looped through results of one query, executing other
> queries.  Is there a better way of doing this?  Is there features in OJB
> that will do this for me?  I was thinking of using the Criteria.addSQL()
and
> add my own nested select code.
>
> Any Ideas?
> Graham
>
> ============================================
>   Graham Lounder
>   Java Developer
>   Spatial Components Division
>   CARIS
>   264 Rookwood Ave
>   Fredericton NB E3B-2M2
>   Office 506 462-4263
>   Fax    506 459-3849
>   [EMAIL PROTECTED]
>   http://www.spatialcomponents.com
> ============================================
>
>
> --
> To unsubscribe, e-mail:   <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>

Reply via email to