Re: [Simple-support] Multiple Objects in One File
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2008-06-03 18:59:16
|
Hi, So are you writing multiple separate objects to the file or are you writing one large object. The ids should not repeat as each write and read operation gets a new session created, so although the ids may be the same you will be able to deserialize them separately without any issues using the Persister. However if your document is for external consumption by DOM or SAX or something similar then overriding the getKey() object seems like a reasonable solution. Niall --- Ben Wolfe <si...@be...> wrote: > > Timo > > Yes, I was able to get this effect by writing to the > same stream > multiple times. However, when I did that the > internal ids that > simpleframework puts into the xml document got > repeated. This caused > errors when reading the same stream back in with > simpleframework. > > I fixed this by changing the "key" value that > WriteGraph.getKey() > returns to be done off of an incrementing static > variable instead of the > size of the current graph. > > Niall, is there a better way to do that? > > Ben > > Niall Gallagher wrote: > > Hi, > > > > For some reason I did not get the original message > or > > the follow up to this. It must have gone in to my > spam > > folder. > > > > In answer to your question yes, you can stream > many > > objects to one file. Also, simple should be much > more > > memory efficient than XStream at just about > > everything. > > > > Niall > > > > --- Timo Rumland <cr...@ol...> wrote: > > > >> Hello Alan, > >> > >>> It's not jumping out at me. Is there an > interface > >> where you can > >>> write multiple objects to one file? XStream has > >> object streams for > >>> this purpose... > >> the only way I know is to have a class that wraps > >> references to the > >> objects you would like to serialize. > >> > >> Say we have ObjectA, ObjectB and ObjectC. Just > >> create a class that has > >> references to each of that instances and > serialize > >> that class. > >> > >> I'm not really an expert on SimpleXML, but this > is > >> the only "solution" > >> I know. > >> > >> > >> Regards, > >> Timo > >> > >> > >> > >> > > > ------------------------------------------------------------------------- > >> This SF.net email is sponsored by: Microsoft > >> Defy all challenges. Microsoft(R) Visual Studio > >> 2008. > >> > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > >> _______________________________________________ > >> Simple-support mailing list > >> Sim...@li... > >> > > > https://lists.sourceforge.net/lists/listinfo/simple-support > > > > > > > > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Microsoft > > Defy all challenges. Microsoft(R) Visual Studio > 2008. > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > _______________________________________________ > > Simple-support mailing list > > Sim...@li... > > > https://lists.sourceforge.net/lists/listinfo/simple-support > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio > 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > |