Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 60030 invoked from network); 23 Feb 2007 21:58:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Feb 2007 21:58:15 -0000 Received: (qmail 38098 invoked by uid 500); 23 Feb 2007 21:58:23 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 38073 invoked by uid 500); 23 Feb 2007 21:58:23 -0000 Mailing-List: contact open-jpa-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: open-jpa-dev@incubator.apache.org Delivered-To: mailing list open-jpa-dev@incubator.apache.org Received: (qmail 38064 invoked by uid 99); 23 Feb 2007 21:58:23 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Feb 2007 13:58:23 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=RCVD_IN_SORBS_WEB,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of tommut@gmail.com designates 66.249.82.225 as permitted sender) Received: from [66.249.82.225] (HELO wx-out-0506.google.com) (66.249.82.225) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Feb 2007 13:58:11 -0800 Received: by wx-out-0506.google.com with SMTP id i26so596483wxd for ; Fri, 23 Feb 2007 13:57:50 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=YD9tsB8z1ZQ75QwfX4Li8NPoiIulCgsIX1V+YobLO2BTFArkFlfRlYXbMYnke2sH0cqUgMJCHlGRBEXAaffhq7iQVcI88H0ZLIIMyxs5HHCTpnZTcQO9FsgAjWF00dQhH/gM9B7I+sW3prX0G5mDL+UxkHrnA45tUnVjheZ6nlM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=EUjgUC6R8+6i1/XvA49kh40bl099HXZCknL8Qj8JQAxo4OzYPll5aKXJezKg0HlTFdjJ0haSCH2lgNdlzMGY8Wd7qitkHo1bfO/yw1ZFAz+qm6ZDKrwkpSb9wBWoU3CLkmQn5ywRUiYZ9XR6DdaSs3GYGJUhk2zVKtVSh+MxI7w= Received: by 10.90.56.14 with SMTP id e14mr2700486aga.1172267870211; Fri, 23 Feb 2007 13:57:50 -0800 (PST) Received: from ?9.37.209.204? ( [129.33.49.251]) by mx.google.com with ESMTP id 33sm3528121wra.2007.02.23.13.57.48; Fri, 23 Feb 2007 13:57:48 -0800 (PST) Message-ID: <45DF635C.1040305@gmail.com> Date: Fri, 23 Feb 2007 16:57:48 -0500 From: Tom Mutdosch User-Agent: Thunderbird 2.0b2 (Windows/20070116) MIME-Version: 1.0 To: open-jpa-dev@incubator.apache.org Subject: Re: possible to write a JPA Query to that filters both an Entity and its relationship entities? References: <45DDFB3F.2090205@gmail.com> <5240F16C-5619-4174-8754-6940EE6CCDF8@SUN.com> <7D856CDFE035FF45A0420ACBD71BDD63034FDFF6@repbex02.amer.bea.com> In-Reply-To: <7D856CDFE035FF45A0420ACBD71BDD63034FDFF6@repbex02.amer.bea.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi Patrick, Thanks for the query suggestion. I guess what I was initially thinking of doing was incorrect in that JPA doesn't really give me a "view" of what I want. That is, I can never get a Department object containing a list of filtered Employees. A JPA object returned from a query is always going to be an exact representation of the database. So your Department object is always going to contain all of the Employees in its relationship. So like you mentioned, I can still get all the information using one query, and then just process those results as I want them. I imagine that this would entail some sort of wrapper bean that would house the Department and the filtered list of Employees. Or what if I added a regular method to my Department entity called getFilterEmployees() which would return a List that I populated with the filtered results from my query? Does that seem like a reasonable thing to do -- if I didn't want to deal with a wrapper object but still have all of my desired data captured by a single Entity? Thanks Tom Patrick Linskey wrote: > It is, but it doesn't buy you much in this situation -- the oldTimers > collection in your example won't be filtered to just the ones that are > old. It'll be all the employees in the dept. > > -Patrick > >