Return-Path: X-Original-To: apmail-openjpa-users-archive@minotaur.apache.org Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0DB791AB3 for ; Tue, 19 Apr 2011 12:56:34 +0000 (UTC) Received: (qmail 82558 invoked by uid 500); 19 Apr 2011 08:56:34 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 82515 invoked by uid 500); 19 Apr 2011 08:56:34 -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 82505 invoked by uid 99); 19 Apr 2011 08:56:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Apr 2011 08:56:33 +0000 X-ASF-Spam-Status: No, hits=2.0 required=5.0 tests=FREEMAIL_FROM,RFC_ABUSE_POST,SPF_NEUTRAL,T_TO_NO_BRKTS_FREEMAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: 216.139.236.26 is neither permitted nor denied by domain of kukismen@gmail.com) Received: from [216.139.236.26] (HELO sam.nabble.com) (216.139.236.26) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Apr 2011 08:56:26 +0000 Received: from jim.nabble.com ([192.168.236.80]) by sam.nabble.com with esmtp (Exim 4.69) (envelope-from ) id 1QC6j8-0006us-6V for users@openjpa.apache.org; Tue, 19 Apr 2011 01:56:06 -0700 Date: Tue, 19 Apr 2011 01:56:06 -0700 (PDT) From: QkI To: users@openjpa.apache.org Message-ID: <1303203366152-6286468.post@n2.nabble.com> Subject: Problem with fetching relation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Hi, I've got a problem during fetching @ManyToOne relations. Consider following persistent classes: @Entity @Table(name =3D "x") @Inheritance(strategy =3D InheritanceType.JOINED) @DiscriminatorColumn(name =3D "jdoclass", length =3D 255) @DiscriminatorStrategy("org.apache.openjpa.jdbc.meta.strats.ClassNameDiscri= minatorStrategy") public class X { @Id @Column(name =3D "id") private int id; } @Entity @Table(name =3D "b") public class B extends X { @Column(name =3D "name") private String name; } @Entity @Table(name =3D "a") public class A extends X { @ManyToOne @JoinColumn(name =3D "b_id") private B b; } The following test fails always. @Test public void test2() { EntityManager em =3D context.getEm(); List results =3D em.createQuery("SELECT e FROM X e").getResultList()= ; assertTrue(results.size() =3D=3D 2); for(X x : results) { if(x instanceof A) { A a =3D (A) x; assertNotNull(a.getB()); } } em.close(); } @Before public void init() { context.init(); EntityManager em =3D context.getEm(); EntityTransaction et =3D em.getTransaction(); try { et.begin(); B b =3D new B(); b.setId(101); b.setName("test"); A a2 =3D new A(); a2.setB(b); a2.setId(102); a2.setNo(2); //em.persist(a); em.persist(b); em.persist(a2); et.commit(); } catch (Throwable t) { et.rollback(); } } Does anybody know what might be a reason of this ? PS. When I replaced @ManyToOne relation by primitive field: @Column(name=3D"b_id") private int bId; everything works, but I'm not a big fun of such workaround. Regards, Pawe=C5=82 -- View this message in context: http://openjpa.208410.n2.nabble.com/Problem-w= ith-fetching-relation-tp6286468p6286468.html Sent from the OpenJPA Users mailing list archive at Nabble.com.