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