Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 30810 invoked from network); 28 Jan 2008 15:30:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Jan 2008 15:30:10 -0000 Received: (qmail 54860 invoked by uid 500); 28 Jan 2008 15:30:00 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 54853 invoked by uid 500); 28 Jan 2008 15:30:00 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 54844 invoked by uid 99); 28 Jan 2008 15:30:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jan 2008 07:30:00 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jean-paul.lefevre@cea.fr designates 132.166.172.107 as permitted sender) Received: from [132.166.172.107] (HELO sainfoin-out.extra.cea.fr) (132.166.172.107) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jan 2008 15:29:31 +0000 Received: from cyclose2.extra.cea.fr (cyclose2.extra.cea.fr [132.167.198.23]) by sainfoin.extra.cea.fr (8.14.2/8.14.2/CEAnet-Internet-out-1.0) with ESMTP id m0SFTa5t013216 for ; Mon, 28 Jan 2008 16:29:36 +0100 Received: from orpin2.extra.cea.fr (orpin2.extra.cea.fr [132.167.198.5]) by cyclose2.extra.cea.fr (8.13.8/8.13.8) with ESMTP id m0SFTaQ1019933 for ; Mon, 28 Jan 2008 16:29:36 +0100 (envelope-from jean-paul.lefevre@cea.fr) Received: from dappcj205.extra.cea.fr (dappcj205.extra.cea.fr [132.166.9.205]) by orpin2.extra.cea.fr (8.13.8/8.13.8/CEAnet-Extranet-out-1.0) with ESMTP id m0SFTa5S029221 for ; Mon, 28 Jan 2008 16:29:36 +0100 From: Jean-Paul Le =?iso-8859-1?q?F=E8vre?= Organization: CEA DAPNIA To: user@cayenne.apache.org Subject: Re: Problem concerning Prefetching Date: Mon, 28 Jan 2008 16:29:35 +0100 User-Agent: KMail/1.9.7 References: <200801241710.05960.jean-paul.lefevre@cea.fr> <200801281431.07701.jean-paul.lefevre@cea.fr> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200801281629.35874.jean-paul.lefevre@cea.fr> X-Virus-Checked: Checked by ClamAV on apache.org On Monday 28 January 2008, Michael Gentry wrote: > Hi Jean-Paul, Hi Michael and Andrus, > > It looks like galaxy -> galaxy_component_properties is a to-one > relationship, which would cause Cayenne to issue multiple selects like > this since it tries to resolve each fault individually. It's a one to many : each galaxy has 3 different types of properties. Here is the code (simplified) implementing my method : public final List selectGalaxies(int timestep)=20 { StringBuffer buf =3D new StringBuffer("halo.simulation.name =3D '"); buf.append(getCurrentSimulationName()); buf.append("' and halo.properties.timestep =3D "); buf.append(timestep); Expression exp =3D Expression.fromString(buf.toString()); SelectQuery query =3D new SelectQuery(Galaxy.class, exp); query.addOrdering("number", true); //query.addPrefetch("componentProperties");=20 return (List) performQuery(query); } And here is how I use it : galaxies =3D handler.selectGalaxies(ts); // Loop on galaxies, get the disc component and the mass of baryons. for (Galaxy g : galaxies) { GalaxyComponentProperties prop =3D g.getComponentProperties("disc"); if (prop !=3D null) { printer.println(g.getNumber() + ", " + prop.getMassOfBaryons().toString()); } } > > Given your manual SQL statement: > > select galaxies.number, galaxy_component_properties.mass_of_baryons > from galaxy_component_properties > join galaxies on galaxy_component_properties.galaxy_id =3D galaxies= =2Eid > where some_clause > order by galaxies.number; > > It looks like you don't actually care about having actual Cayenne > objects (it looks like you only care about having two of the > attributes)? If this is the case, you could use an SQLTemplate and > raw data rows to only fetch in those two properties. If this isn't > the case, let us know and we'll give you other ideas. In fact you asked the good question. I'm just at the beginning of the=20 development and I don't really know how the application will be used and as= a=20 consequence it is hard to figure out what it the best strategy to implement= =20 the functionalities : I guess that some users are only interested in=20 computing mean values, sums, min, max in big chunks of data but others wan= t=20 to retrieve all the attributes of a small amount of specific objects. The=20 challenge is to make both types of users happy. I'm wondering whether it is= =20 possible or not. In my experience Cayenne has always been excellent at manipulating small=20 numbers of complex objects but, on the other hand, difficult to use on huge= =20 dataset. =2D-=20 ___________________________________________________________________ Jean-Paul Le F=E8vre * Mail : LeFevre@fonteny.org