Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 67237 invoked from network); 16 Dec 2008 15:53:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Dec 2008 15:53:17 -0000 Received: (qmail 77304 invoked by uid 500); 16 Dec 2008 15:53:29 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 77095 invoked by uid 500); 16 Dec 2008 15:53:29 -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 77084 invoked by uid 99); 16 Dec 2008 15:53:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Dec 2008 07:53:29 -0800 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists+1214986160035-208411@n2.nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Dec 2008 15:53:08 +0000 Received: from tervel.nabble.com ([192.168.236.150]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1LCcE1-0004AX-IA for users@openjpa.apache.org; Tue, 16 Dec 2008 07:52:46 -0800 Message-ID: <1229442765558-1663486.post@n2.nabble.com> Date: Tue, 16 Dec 2008 07:52:45 -0800 (PST) From: Pinaki Poddar To: users@openjpa.apache.org Subject: Re: Lazy initialisation questions In-Reply-To: <4947B7E8.9090205@graniteds.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: ppoddar@apache.org References: <4947B7E8.9090205@graniteds.org> X-Virus-Checked: Checked by ClamAV on apache.org Hi, Hopefully, you are familiar with configuration options that may be relevant in similar scenarios. For example, DetachState flags such as "AccessUnloaded". > *1. How do I figure out what fields of a detached object are > uninitialized?* The bit index of getLoaded() are same as the index used in ClassMetaData. So the following *should* work (but I am writing this on-line without testing, please verify) PersistenceCapable pc = (PersistenceCapable)myEntity; OpenJPAStateManager sm = (OpenJPAStateManager)pc.pcGetStateManager(); BitSet loaded = sm.getLoaded(); for (int i = 0; i < loaded.size(); i++) { FieldMetaData fmd = sm.getMetaData().getField(i); System.err.println(fmd.getFullName() + (loaded.get(i) ? ": loaded" ? ": not loaded"); } > 2. How do I get the id of a uninitialized single-valued association > object?* > I have seen this in some code sample (but, again, I need to know the > index of the Java field): > Object proxy = > ((OpenJPAStateManager)pc.pcGetStateManager()).getIntermediate(index); > Object id = ((OpenJPAId)proxy).getIdObject(); > Is it reliable? Bit hacky, might work. But what is the usage? If the single-valued association object is not fetched during detach, the remote tier will not have access to it anyway. If it has been fetched during detach, then there will be more direct (and kosher) way to get its identifier's value. > *3. How do I recreate an OpenJPA detached object?* Tough. Thinking... But why? -- View this message in context: http://n2.nabble.com/Lazy-initialisation-questions-tp1662940p1663486.html Sent from the OpenJPA Users mailing list archive at Nabble.com.