hi yuriy , you can easily optimize the number of queries using prefetched relationships.
Query query; Criteria crit; crit = new Criteria(); crit.addPrefetchedRelationship("company"); ... hth jakob ----- Original Message ----- From: "Yuriy Zubarev" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, November 26, 2002 10:26 PM Subject: 1:1 queries are not optimized > Hello everyone, > > Let's say I have 2 object: Company and Contact. Contact has > attribute 'company' of type Company as a look up value. > (in database it's two table 'companies' and 'contacts' where > the latter has foreign key to the former) > > Now I need to show list of contacts with company name for > each contact. In repository.xml class-descriptor for Contact > has reference-descriptor pointing to Company (typical 1:1 > mapping). When contact list gets displayed with 10 rows, > OJB (PB) executes 11 queries: 1 - to get contact and then 10 > to get Company info for every contact. > > 11 queries with this simple case (in real situation it's much more) > is just not acceptable. > > Is there a way for OJB to issue only one query to get all information? > > Any hint is greatly appreciated! > > Yuriy Zubarev > > > > __________________________________________________ > Do you Yahoo!? > Yahoo! Mail Plus - Powerful. Affordable. Sign up now. > http://mailplus.yahoo.com > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>