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 B9ECADEF3 for ; Wed, 26 Sep 2012 09:20:23 +0000 (UTC) Received: (qmail 52357 invoked by uid 500); 26 Sep 2012 09:20:23 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 52189 invoked by uid 500); 26 Sep 2012 09:20:20 -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 52142 invoked by uid 99); 26 Sep 2012 09:20:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Sep 2012 09:20:19 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [194.109.24.39] (HELO smtp-vbr19.xs4all.nl) (194.109.24.39) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Sep 2012 09:20:10 +0000 Received: from remote.huizemolenaar.nl (D57D0452.static.ziggozakelijk.nl [213.125.4.82]) (authenticated bits=0) by smtp-vbr19.xs4all.nl (8.13.8/8.13.8) with ESMTP id q8Q9JnLP073859 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL) for ; Wed, 26 Sep 2012 11:19:49 +0200 (CEST) (envelope-from henno@huizemolenaar.nl) Received: from HMS.hm.local ([fe80::6051:4a91:4c0d:d963]) by HMS.hm.local ([fe80::6051:4a91:4c0d:d963%11]) with mapi; Wed, 26 Sep 2012 11:19:52 +0200 From: Henno Vermeulen To: "'users@openjpa.apache.org'" Date: Wed, 26 Sep 2012 11:19:51 +0200 Subject: RE: How to add children to disconnected entity? Thread-Topic: How to add children to disconnected entity? Thread-Index: Ac2baY/J3Rt7NeD5R1qBqoPeZkvrSAAVluQw Message-ID: <1C448C478A6B4743AF19DBC3C3DCE1320394ACBC9FEC@HMS.hm.local> References: <506229EF.9000004@spudsoft.co.uk> In-Reply-To: <506229EF.9000004@spudsoft.co.uk> Accept-Language: nl-NL Content-Language: nl-NL X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: nl-NL Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Scanned: by XS4ALL Virus Scanner Hi, I verified this situation by making an extra unit test in our system. We al= ways work with detached entities as well. The test works fine for me. One explanation for this behavior is that the @OneToMany field does not use= "fetch =3D FetchType.EAGER" because relations are lazily fetched by defaul= t. (Or alternatively you have not included the field in OpenJPA's FetchPlan= before calling entityManager.merge which has the same effect as FetchType.= EAGER even if the @OneToMany field is not eager). When I adjust my test to lazily fetch the field, then saving a new Assessme= nt somehow DOES cascade merge new AssessmentResults. However when I merge a= n existing Assessment that has one existing AssessmentResult and one new As= sessmentResult, OpenJPA will not cascade merge it. -----Oorspronkelijk bericht----- Van: Jim Talbut [mailto:jtalbut@spudsoft.co.uk]=20 Verzonden: woensdag 26 september 2012 0:02 Aan: 'users@openjpa.apache.org' Onderwerp: How to add children to disconnected entity? Hi, I have a pair of entities: Assessment & AssessmentResults, with a=20 One-to-Many relationship (an assessment can have many results). The Assessment is modified whilst disconnected (outside of a transaction). Is there any way to have AssessmentResults added whilst the Assessment=20 is disconnected be persisted automatically when the Assessment gets merged? Setting CascadeType.Merge doesn't seem to do it (I think that merges=20 existing children, not adds new children). Thanks Jim