From dev-return-17115-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Fri Aug 13 10:13:43 2010 Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 74923 invoked from network); 13 Aug 2010 10:13:42 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 13 Aug 2010 10:13:42 -0000 Received: (qmail 21378 invoked by uid 500); 13 Aug 2010 10:13:42 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 20974 invoked by uid 500); 13 Aug 2010 10:13:39 -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 20953 invoked by uid 99); 13 Aug 2010 10:13:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Aug 2010 10:13:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Aug 2010 10:13:37 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o7DADFQr010052 for ; Fri, 13 Aug 2010 10:13:17 GMT Message-ID: <6869071.327551281694395839.JavaMail.jira@thor> Date: Fri, 13 Aug 2010 06:13:15 -0400 (EDT) From: =?utf-8?Q?=C5=81ukasz_Ostaniewicz_=28JIRA=29?= To: dev@openjpa.apache.org Subject: [jira] Created: (OPENJPA-1766) Polymorphic queries, selecting all childres - different result depending on select phrase MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Polymorphic queries, selecting all childres - different result depending on= select phrase ---------------------------------------------------------------------------= -------------- Key: OPENJPA-1766 URL: https://issues.apache.org/jira/browse/OPENJPA-1766 Project: OpenJPA Issue Type: Bug Components: jpa Affects Versions: 2.0.0 Environment: windows 7, jdk1.5.0_22 Reporter: =C5=81ukasz Ostaniewicz Priority: Minor I've got simple inheritance entity tree: @Entity=20 @Table(name =3D "mgruchmagazynowy", schema=3D"magazyn") @Inheritance(strategy=3DInheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name=3D"rodzaj",discriminatorType=3DDiscriminatorType.= INTEGER,length=3D1) public class RuchMagazynowy implements Serializable { =09(...) } @Entity @DiscriminatorValue(value=3D"0") public class Dostawa extends RuchMagazynowy { =09(...) } @Entity @DiscriminatorValue(value=3D"1") public class Wydanie extends RuchMagazynowy { } I've got two rows in "magazyn.mgruchmagazynowy" table: one with "rodzaj" se= t to 0 and one with "rodzaj" set to 1 I'm trying to select all children (both Dostawa and Wydanie) and distinguis= h beetwen them: iterating over the results and using .getClass() or instanc= eof. My JUNIT test looks like: =09List list =3D dao.findRM(); =09for (int i =3D 0; i < list.size(); i++) { =09=09final Object[] row =3D (Object[]) list.get(i); =09=09final Class clazz1 =3D row[0].getClass(); =09=09final Class clazz2 =3D row[1].getClass(); =09=09log.info("class1:" + clazz1); =09=09log.info("class2:" + clazz2); =09} The problem is: I cannot achieve this if I don't specify TYPE(u) amoung SEL= ECT items on my SELECT phrase. I thing the results of my both test cases sh= ould be equal (As I think, only test case 2 results gives correct results). TEST CASE 1: =09String select =3D "SELECT u,e FROM RuchMagazynowy u, ElementRuchuMagazyn= owego e " + =09=09" WHERE u.id =3D e.ruchMagazynowy.id "; =09query =3D em.createQuery(select); =09List items =3D query.getResultList(); RESULT: 2890 [main] INFO org - class1:class pl.imedia.magazyn.bo.RuchMagazynowy 2890 [main] INFO org - class2:class pl.imedia.magazyn.bo.ElementRuchuMagaz= ynowego 2890 [main] INFO org - class1:class pl.imedia.magazyn.bo.RuchMagazynowy 2890 [main] INFO org - class2:class pl.imedia.magazyn.bo.ElementRuchuMagaz= ynowego TEST CASE 2: =09String select =3D "SELECT u,e, TYPE(u) FROM RuchMagazynowy u, ElementRuc= huMagazynowego e " + =09=09" WHERE u.id =3D e.ruchMagazynowy.id "; =09query =3D em.createQuery(select); =09List items =3D query.getResultList(); RESULT: 2864 [main] INFO org - class1:class pl.imedia.magazyn.bo.Dostawa 2864 [main] INFO org - class2:class pl.imedia.magazyn.bo.ElementRuchuMagaz= ynowego 2864 [main] INFO org - class1:class pl.imedia.magazyn.bo.Wydanie 2864 [main] INFO org - class2:class pl.imedia.magazyn.bo.ElementRuchuMagaz= ynowego --=20 This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.