Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 31103 invoked from network); 13 Jun 2007 09:40:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Jun 2007 09:40:51 -0000 Received: (qmail 65962 invoked by uid 500); 13 Jun 2007 09:40:49 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 65911 invoked by uid 500); 13 Jun 2007 09:40:48 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 65900 invoked by uid 99); 13 Jun 2007 09:40:48 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jun 2007 02:40:48 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [206.190.37.42] (HELO web53609.mail.re2.yahoo.com) (206.190.37.42) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 13 Jun 2007 02:40:44 -0700 Received: (qmail 85795 invoked by uid 60001); 13 Jun 2007 09:40:23 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=J0I7LE1+WuFu4xc8jDEQBBbITLay2yzI5dWt0HmN1PzPqDXfksjQvTC3R4VnrF20fgHxM4ANsfopG+UCkpFOq/vll0skm82ZaIivyWGsecvtfefItJru9lsZPx/NwJb/MTkvxgxlM6+UidnDzZPI9W8BNN+js9V+h+1ueE3a3sA=; X-YMail-OSG: NLuUxT0VM1k7H2X5i297Am4OIOcsZ7y12y7nrMo4T0dj5uhMmYAxzMMGD_sNERBpZA-- Received: from [69.233.190.178] by web53609.mail.re2.yahoo.com via HTTP; Wed, 13 Jun 2007 02:40:23 PDT Date: Wed, 13 Jun 2007 02:40:23 -0700 (PDT) From: "Armin M. Garcia" Subject: betwixt - Hibernate - Lazy Initialization Exception To: commons-user@jakarta.apache.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1599561084-1181727623=:84855" Content-Transfer-Encoding: 8bit Message-ID: <203515.84855.qm@web53609.mail.re2.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org --0-1599561084-1181727623=:84855 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit I am using betwixt to marshal a domain object initialized from Hiberate. Is there a way to generate a static (stub) XML element when a proxy object is detected? The domain object being considered is a node in an n-ary tree and therefore contains references to other child nodes. I've declared the child relationship to be a list that is initialized lazily since not doing so will retrieve the whole graph causing a significant delay. The lazy initialization creates a proxy used to retrieve the actual node if called in the context of a transaction. Outside of a transaction, accessing the proxy will throw a Lazy Initialization Exception. I am taking this single node and writing it to XML. The introspection returns a complete description of the root node being considered. In addition, a descriptor for the list of child nodes is also returned. At the time the bean is being written, the node attributes, in particular, the child nodes are interrogated. The child nodes are clearly defined by a Hibernate proxy and therefore complain when the writer makes an effort to write the corresponding XML element for the list. Setting a class normalizer through 'setClassNormalizer' only captures the top level bean but not its attributes (ie. the list of child nodes). Consider the following example: Node: ID = 1 List children = (NodeProxy[ID=2], NodeProxy[ID=3]) The xml I'm trying to accomplish would be like: Any ideas would be appreciated. -Armin --------------------------------- Need a vacation? Get great deals to amazing places on Yahoo! Travel. --0-1599561084-1181727623=:84855--