Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 13060 invoked from network); 14 Mar 2009 21:36:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Mar 2009 21:36:34 -0000 Received: (qmail 48416 invoked by uid 500); 14 Mar 2009 21:36:34 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 48406 invoked by uid 500); 14 Mar 2009 21:36:34 -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 48395 invoked by uid 99); 14 Mar 2009 21:36:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 Mar 2009 14:36:34 -0700 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 robert.zeigler@gmail.com designates 209.85.132.242 as permitted sender) Received: from [209.85.132.242] (HELO an-out-0708.google.com) (209.85.132.242) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 Mar 2009 21:36:26 +0000 Received: by an-out-0708.google.com with SMTP id b6so1286606ana.37 for ; Sat, 14 Mar 2009 14:36:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=6gDHGaSjQu02uaN7yHHNxUt3Hx5c+7joZv2ZZBmCotw=; b=DQtreMKJy19vAMzPOwGY6JbctCCRFl9/xFk79WvWcFwrzEWfKEcBWwMi8XT587LomL alzX4mSrj4ql0OCYSxuFPIEYXRVW9jbzl7yqc+zaPdYaN6hb0Jv1XXenlFk4IUH9VGt4 T2X7mfbzpyLOs3o0cNDbKNkSWLemkJ6+I9xNI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=D1uaIShO6702XTN1xrNwrJgfyRrKt8pgCnpFO7eben6eQ1MHqEwwYiXLtnKMjDclK0 zIrtJpezC5NZEP5aEiI3DmzxVZKl2P9Bm0opo08d4u0l/gdYpqxO4ACjzcHqCjiLofFI R4X8DApb768nbK7VJBpV6jgI5nmssKz6C8thI= Received: by 10.100.13.2 with SMTP id 2mr514868anm.57.1237066565185; Sat, 14 Mar 2009 14:36:05 -0700 (PDT) Received: from ?192.168.0.2? (ppp-70-246-220-170.dsl.stlsmo.swbell.net [70.246.220.170]) by mx.google.com with ESMTPS id c23sm5643783ana.52.2009.03.14.14.36.03 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 14 Mar 2009 14:36:04 -0700 (PDT) Message-Id: <4FE6EB58-EC6F-435A-9A6E-4CFC4820E30D@puregumption.com> From: Robert Zeigler To: user@cayenne.apache.org In-Reply-To: <33002EFC-BBA0-42AE-AF31-A5254F3A9A96@earthlink.net> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Re: Qualifier Expression Date: Sat, 14 Mar 2009 16:36:02 -0500 References: <85996577-B7D6-4904-9DD1-CD5C427FDD76@earthlink.net> <45F555BA-7356-4037-9F62-75893526E518@puregumption.com> <33002EFC-BBA0-42AE-AF31-A5254F3A9A96@earthlink.net> X-Mailer: Apple Mail (2.930.3) X-Virus-Checked: Checked by ClamAV on apache.org On Mar 14, 2009, at 3/144:22 PM , Joe Baldwin wrote: > Robert, > > I am attempting a test but lost you on your Qualifier step. > >> SelectQuery query = new SelectQuery(Entity1.class); > > This is easy. > >> query.setQualifier(ExpressionFactory.matchExp(Entity1.EN| >> TITY2_PROPERTY,entity2));//where ENTITY2_PROPERTY is the name of >> object property in entity1 that points to entity2 > > I don't follow this step. You are obviously using the > ExpressionFactory to create a qualifier expression for the query but > I don't follow the match expression. > > Lets say that entity1 is "Customer" and entity2 is "Detail". So the > code snippet would be > ExpressionFactory.matchExp(Customer.DETAIL_PROPERTY, entity2) > > I don't understand what entity2 stands for in this example. In > addition, I am trying to select based on the contents of the entity2 > field, so I am even more confused as to how this would accomplish > that objective. > Ok, Customer -> Detail. I'm still a little unclear on exactly what you're trying to do, based on your comment "based on the contents of the entity2 field", so I'll step through two scenarios: 1) You have a "detail" object reference, and you want to get the corresponding "customer". Then entity2 would be your detail object. ExpressionFactory.matchExp() takes a property path as its first argument and the corresponding value to match as its second. So, ExpressionFactory .matchExp(Customer.DETAIL_PROPERTY,someDetailForWhichYouHaveAReference); Of course, if this is a two-sided one-to-one (detail has a property for customer, as well as customer having a property for detail), then you could always just do: detail.getCustomer(); :) 2) You have some information related to a property of detail, say, "description". So the property path, from customer, might look like: "detail.description" (assuming customer is the root object of the property path). Or, you could write it as: Customer.DETAIL_PROPERTY + "." + Detail.DESCRIPTION_PROPERTY So you could do: ExpressionFactory.matchExp(Customer.DETAIL_PROPERTY + "." + Detail.DESCRIPTION_PROPERTY,"the description string") Or you could use a like expression: ExpressionFactory.likeExp(Customer.DETAIL_PROPERTY + "." + Detail.DESCRIPTION_PROPERTY,"the description to partial match");//<-- add % wildcards yourself here. HTH, Robert >> List e1 = objectContext.performQuery(query);//note: >> perform query is NOT generified, so you'll get a warning here. > > > This seems easy as well. > > > Thanks, > Joe > > > On Mar 14, 2009, at 3:53 PM, Robert Zeigler wrote: > >> Hi Joe, >> >> How about: >> >> SelectQuery query = new SelectQuery(Entity1.class); >> query.setQualifier(ExpressionFactory.matchExp(Entity1.EN| >> TITY2_PROPERTY,entity2));//where ENTITY2_PROPERTY is the name of >> object property in entity1 that points to entity2 >> List e1 = objectContext.performQuery(query);//note: >> perform query is NOT generified, so you'll get a warning here. >> >> Robert >> >> On Mar 14, 2009, at 3/141:29 PM , Joe Baldwin wrote: >> >>> I am attempting to create the simplest Cayenne-expedient method of >>> doing the following query. (I can easily do this in SQL but am a >>> tad confused with the Cayenne Expression method.) >>> >>> I have an Entity (E1) with a one to one relationship with a second >>> entity (E2). I would like to perform a SELECT Query with a filter >>> on one of the fields of the relationship-entity (E2.F1) and return >>> a list of the first entity (E1List). >>> >>> What is the most efficient Cayenne way to do this? (I am still a >>> bit confused concerning how to construct efficient queries in the >>> object domain vs the relational domain.) >>> >>> Thanks, >>> Joe >>> >>> >>> >> >