-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: XML Marshalling/Unmarshalling Sets
PostPosted: Thu Jun 03, 2004 8:37 am 
Newbie

Joined: Thu Jun 03, 2004 7:25 am
Posts: 1
Hello all,

My application needs some flatfile-intermediate storage of data. So I thought of Marshalling my data in an XML-format, using XMLEncoder. This worked well. I wrote my own persistenceDelegate for the Enummerations and then this works:

Code:
  RSA rsa = rsaDao.load(rsaId);
  container.add(rsa)
  xmlStream.writeObject(container);

this delivers something like:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.4.2_04" class="java.beans.XMLDecoder">
<object class="com.aab.race.business.shared.sync.RaceSyncContainer">
  <void property="RSAs">
   <object class="java.util.ArrayList">
    <void method="add">
     <object class="com.aab.race.business.shared.entity.RSA">
      <void property="RSAName">
       <string>New</string>
        .... etc


But this doesn't marshal my Sets. To fix that I wrote my own PersistenceDelegate to handle the hybernate Set. This works, so I get the following output (still with a LazyInitializationException but ... the output looks fine):

Code:
      <void property="objectives">
       <object class="net.sf.hibernate.collection.Set">
        <void method="add">
         <object class="com.aab.race.business.shared.entity.Objective">
          <void property="copiedFromORL">
           <object idref="Boolean0"/>
          </void>
          <void property="id">
           <int>655362</int>
          </void>
         </object>
        </void>


But now..... Now unmarshalling this doesn't work. XMLDecode will try to instantiate a Set, and add my Objectives to it, but this results in LazyInitializationsExceptions offcourse, because new Set(); set.add(x) won't work.

The questiong:
How can I make this work? I saw others using Castor, but won't that have the same problem? Or do I need some intermediate classes, non-persistent? How can I do this without writing it all myself?

Thanks,
Eelco


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.