Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 62720 invoked from network); 23 Feb 2007 22:07:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Feb 2007 22:07:28 -0000 Received: (qmail 50298 invoked by uid 500); 23 Feb 2007 22:07:36 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 50276 invoked by uid 500); 23 Feb 2007 22:07:36 -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 50267 invoked by uid 99); 23 Feb 2007 22:07:36 -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 14:07:36 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of plinskey@bea.com designates 66.248.192.21 as permitted sender) Received: from [66.248.192.21] (HELO usremg01.bea.com) (66.248.192.21) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Feb 2007 14:07:24 -0800 Received: from usremr02.bea.com (usremr02.bea.com [10.160.29.92]) by usremg01.bea.com (Switch-3.2.2/Switch-3.2.2) with ESMTP id l1NM72cc017533 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Fri, 23 Feb 2007 14:07:02 -0800 Received: from repbex02.amer.bea.com (repbex02.bea.com [10.160.26.99]) by usremr02.bea.com (Switch-3.2.2/Switch-3.2.2) with ESMTP id l1NM710b017268 for ; Fri, 23 Feb 2007 14:07:01 -0800 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: possible to write a JPA Query to that filters both an Entity and its relationship entities? Date: Fri, 23 Feb 2007 14:06:56 -0800 Message-ID: <7D856CDFE035FF45A0420ACBD71BDD63034FE2D6@repbex02.amer.bea.com> In-Reply-To: <45DF635C.1040305@gmail.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: possible to write a JPA Query to that filters both an Entity and its relationship entities? Thread-Index: AcdXlbnyzBjZ7v7AQ5mxnoGhIJTiuQAANS4A References: <45DDFB3F.2090205@gmail.com> <5240F16C-5619-4174-8754-6940EE6CCDF8@SUN.com> <7D856CDFE035FF45A0420ACBD71BDD63034FDFF6@repbex02.amer.bea.com> <45DF635C.1040305@gmail.com> From: "Patrick Linskey" To: X-PMX-Version: 4.7.1.128075, Antispam-Engine: 2.5.0.283055, Antispam-Data: 2007.2.21.151434 X-Virus-Checked: Checked by ClamAV on apache.org You could do that, but personally, I tend to be wary of putting computed data into the entity types themselves. You're in the grey area in the question of when to use your domain model as a DTO graph vs. creating a separate set of DTOs. -Patrick --=20 Patrick Linskey BEA Systems, Inc.=20 _______________________________________________________________________ Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.=20 > -----Original Message----- > From: Tom Mutdosch [mailto:tommut@gmail.com]=20 > Sent: Friday, February 23, 2007 1:58 PM > To: open-jpa-dev@incubator.apache.org > Subject: Re: possible to write a JPA Query to that filters=20 > both an Entity and its relationship entities? >=20 > Hi Patrick, > Thanks for the query suggestion. I guess what I was=20 > initially thinking=20 > of doing was incorrect in that JPA doesn't really give me a "view" of=20 > what I want. That is, I can never get a Department object=20 > containing a=20 > list of filtered Employees. A JPA object returned from a query is=20 > always going to be an exact representation of the database. So your=20 > Department object is always going to contain all of the=20 > Employees in its=20 > relationship. >=20 > So like you mentioned, I can still get all the information using one=20 > query, and then just process those results as I want them. I imagine=20 > that this would entail some sort of wrapper bean that would house the=20 > Department and the filtered list of Employees. Or what if I added a=20 > regular method to my Department entity called=20 > getFilterEmployees() which=20 > would return a List that I populated with the filtered=20 > results from my=20 > query? Does that seem like a reasonable thing to do -- if I=20 > didn't want=20 > to deal with a wrapper object but still have all of my desired data=20 > captured by a single Entity?=20 >=20 > Thanks > Tom >=20 >=20 > Patrick Linskey wrote: > > It is, but it doesn't buy you much in this situation -- the=20 > oldTimers > > collection in your example won't be filtered to just the=20 > ones that are > > old. It'll be all the employees in the dept. > > > > -Patrick > > > > =20 >=20