Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 96855 invoked from network); 23 Dec 2009 20:23:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 23 Dec 2009 20:23:15 -0000 Received: (qmail 95453 invoked by uid 500); 23 Dec 2009 20:23:14 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 95388 invoked by uid 500); 23 Dec 2009 20:23:14 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 95377 invoked by uid 99); 23 Dec 2009 20:23:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Dec 2009 20:23:14 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00 X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists+1214986160035-208411@n2.nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Dec 2009 20:23:05 +0000 Received: from jim.nabble.com ([192.168.236.80]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1NNXjI-0004jc-QJ for users@openjpa.apache.org; Wed, 23 Dec 2009 12:22:44 -0800 Date: Wed, 23 Dec 2009 12:22:44 -0800 (PST) From: baileyby To: users@openjpa.apache.org Message-ID: <1261599764808-4210420.post@n2.nabble.com> Subject: Filtering Results of a Mapped Relationship MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: baileyby Is there a way to filter children of a mapped relationship? For example, I have a simple 3-tiered object structure, Person --(OneToOne)--> AddressChain --(OneToMany using a simple 2 column join table)--> Address In the interest of keeping historical data, I use a status column on records in the Address table, "Active" and "Deleted" When I query to get a "Person" object, I only want it to contain Address objects that are "Active." Unfortunately, doing a simple query like the one below doesn't work, because what happens is that it fetches the person, and then separately under the covers goes and finds ALL associated address chains and addresses via the mapping relationship, including the ones marked Deleted. I don't see any annotations to instruct the mapping to filter by status (at least, in OpenJPA. It seems like hibernate may have a filtering capability). Any ideas? Thanks in advance. SELECT p from Person p, Address a WHERE p.id=? and a.status="Active" I have also tried variations such as the following to no avail. SELECT p, c, a from Person p, AddressChain c, Address a WHERE p.id=? and a.status="Active" -- View this message in context: http://n2.nabble.com/Filtering-Results-of-a-Mapped-Relationship-tp4210420p4210420.html Sent from the OpenJPA Users mailing list archive at Nabble.com.