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 674316A42 for ; Thu, 4 Aug 2011 14:00:50 +0000 (UTC) Received: (qmail 89592 invoked by uid 500); 4 Aug 2011 14:00:50 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 89556 invoked by uid 500); 4 Aug 2011 14:00:49 -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 89548 invoked by uid 99); 4 Aug 2011 14:00:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Aug 2011 14:00:49 +0000 X-ASF-Spam-Status: No, hits=1.6 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of curtisr7@gmail.com designates 209.85.215.170 as permitted sender) Received: from [209.85.215.170] (HELO mail-ey0-f170.google.com) (209.85.215.170) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Aug 2011 14:00:42 +0000 Received: by eyd10 with SMTP id 10so961592eyd.15 for ; Thu, 04 Aug 2011 07:00:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=XMeqo0cKWg03z5LcPO+v+2R9vCgGO40FbcFWbR0nfls=; b=tSeRjh93HaPqYUcX/OBU5r/MT0ZB+a1S6w43v5fEysrJQWjedxgvHmHzMzZf/tDaeA v6s1z08Jw5THEUT0QhN/ogqeeFOhxBJlioV/qV6RFJ56zj3N+qUFBDWKRhAY1bpC7uGE S9GMGZnI/icj/XI0qpDABTwwpo3EYWHiZVt8U= MIME-Version: 1.0 Received: by 10.213.7.199 with SMTP id e7mr672134ebe.140.1312466421477; Thu, 04 Aug 2011 07:00:21 -0700 (PDT) Received: by 10.213.26.9 with HTTP; Thu, 4 Aug 2011 07:00:21 -0700 (PDT) In-Reply-To: References: Date: Thu, 4 Aug 2011 09:00:21 -0500 Message-ID: Subject: Re: NullpointerException when accessing a lazy association after merging the object without a fetch of the lazy entities From: Rick Curtis To: users@openjpa.apache.org Content-Type: multipart/alternative; boundary=0015174c45c2d4f1f804a9ae66cb X-Virus-Checked: Checked by ClamAV on apache.org --0015174c45c2d4f1f804a9ae66cb Content-Type: text/plain; charset=ISO-8859-1 I don't see any issues. Is it possible that you have a TestEntity in your DB that doesn't have any children (bad data) in your DB from a previous run? Also, why are you calling em.merge(..)? That call is unnecessary as the results from your query already are a part of your persistence context. Thanks, Rick On Thu, Aug 4, 2011 at 7:51 AM, Michael Pflueger wrote: > Hi, > > I'm digging through some of my OpenJPA problems and came across this issue. > I get a NPE when I access te2.getChildren().xyz(), but only when I merge > the object before the access AND the lazy association is not yet fetched AND > I set Cascadetype.MERGE on the association. > > List entities = query.getResultList(); > for (TestEntity te : entities) { > TestEntity te2 = em.merge(te); > System.out.println(te2.getChildren().size()); > } > > I'm using OpenJPA 2.1.0 with the MySQL connector. > Attached is the full source and persistence.xml. > > Can anybody reproduce this and is this a bug? > > Regards, > Michael > ___________________________________________________ > > SMA Solar Technology AG > Aufsichtsrat: Guenther Cramer (Vorsitzender) > Vorstand: Juergen Dolle, Roland Grebe, Uwe Hertel, Pierre-Pascal Urbon, > Marko Werner > Handelsregister: Amtsgericht Kassel HRB 3972 > Sitz der Gesellschaft: 34266 Niestetal > USt-ID-Nr. DE 113 08 59 54 > WEEE-Reg.-Nr. DE 95881150 > ___________________________________________________ > -- *Rick Curtis* --0015174c45c2d4f1f804a9ae66cb--