From dev-return-5434-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Fri Aug 10 23:36:06 2007 Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 47112 invoked from network); 10 Aug 2007 23:36:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Aug 2007 23:36:06 -0000 Received: (qmail 85038 invoked by uid 500); 10 Aug 2007 23:36:04 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 85014 invoked by uid 500); 10 Aug 2007 23:36:04 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 85005 invoked by uid 99); 10 Aug 2007 23:36:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Aug 2007 16:36:04 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Aug 2007 23:36:02 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 978DB71403F for ; Fri, 10 Aug 2007 16:35:42 -0700 (PDT) Message-ID: <10299553.1186788942587.JavaMail.jira@brutus> Date: Fri, 10 Aug 2007 16:35:42 -0700 (PDT) From: "Catalina Wei (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Updated: (OPENJPA-313) list of objects returned by query partially correct In-Reply-To: <24208929.1186787742771.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-313?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Catalina Wei updated OPENJPA-313: --------------------------------- Attachment: jpa1.0.0.patch The attached patch seemed to have fixed the problem. The testcase of the Annuity has FetchType EAGER set on both side of a OneToMany relation. An Annuity may have many Payouts. I'd like to get some feedback from commiters before checking in this patch. TCK verification is in process. > list of objects returned by query partially correct > --------------------------------------------------- > > Key: OPENJPA-313 > URL: https://issues.apache.org/jira/browse/OPENJPA-313 > Project: OpenJPA > Issue Type: Bug > Components: jdbc > Reporter: Catalina Wei > Fix For: 1.0.0 > > Attachments: jpa1.0.0.patch > > > We have an object inheritance hierarchy as follows. > FixedAnnuity extends Annuity > EquityAnnuity extends Annuity > Then we have following code: > List annuities = getServerAdapter().findHolderAnnuities(holder); > from which we expect to have a list of "Annuity" (could be Annuity, FixedAnnuity or > EquityAnnuity) from following code > EntityManager em = null; > try{ > em = factory.createEntityManager(); > Query query = em.createNamedQuery("GetHolderAnnuities"); > query.setParameter("holderId", holder.getId()); > return (List) query.getResultList(); > } > Here is the query > > SELECT a FROM Annuity AS a WHERE a.annuityHolderId = :holderId > > In the end, the list returned only the first object with the correct Object, the > rest of the objects all casted into the basic type "Annuity" > e.g. we have following code: > EntityManager em = null; > try{ > em = factory.createEntityManager(); > Query query = em.createNamedQuery("GetHolderAnnuities"); > query.setParameter("holderId", holder.getId()); > return (List) query.getResultList(); > } > > FixedAnnuity fixed1 = new FixedAnnuity(); > fixed1.setHolder(holder); > EquityAnnuity equity1 = new EquityAnnuity(); > equity1.setHolder(holder); > FixedAnnuity fixed1 = new FixedAnnuity(); > fixed2.setHolder(holder); > EquityAnnuity equity2 = new EquityAnnuity(); > equity2.setHolder(holder); > > List annuities = getServerAdapter().findHolderAnnuities(holder); > > Only annuities.get(0) returns the correct object as FixedAnnuity, the other 3 > objects returned all returned as Annuity -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.