commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Armin M. Garcia" <>
Subject betwixt - Hibernate - Lazy Initialization Exception
Date Wed, 13 Jun 2007 09:40:23 GMT
  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
 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:
   ID = 1
   List<Node> children = (NodeProxy[ID=2], NodeProxy[ID=3])
 The xml I'm trying to accomplish would be like:
 <Node ID=1>
        <Proxy classOfChildNode="Node" childID='2">
        <Proxy classOfChildNode="Node" childID='3">
 Any ideas would be appreciated.

Need a vacation? Get great deals to amazing places on Yahoo! Travel. 
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message