serialization

How to Serialize Hibernate Collections Properly?

I'm trying to serialize objects from a database that have been retrieved with Hibernate, and I'm only interested in the objects' actual data in its entirety (cycles included). Now I've been working with XStream, which seems powerful. The problem with XStream is that it looks all too blindly on the information. It recognizes Hibernate's ...

Serialization of objects: no thread state can be involved, right?

I am looking hard at the basic principles of storing the state of an executing program to disk, and bringing it back in again. In the current design that we have, each object (which is a C-level thingy with function pointer lists, kind of low-level home-made object-orientation -- and there are very good reasons for doing it this way) wi...

Configuration file with list of key-value pairs in python

I have a python scripts that analyzes a set of error messages and checks for each message if it matches a certain pattern (regular expression) in order to group these messages. For example "file x does not exist" and "file y does not exist" would match "file .* does not exist" and be accounted as two occurrences of "file not found" categ...

Is it possible to set a default value when deserializing xml in C# (.NET 3.5)?

Hello all, I've got a little problem that's slightly frustrating. Is it possible to set a default value when deserializing xml in C# (.NET 3.5)? Basically I'm trying to deserialize some xml that is not under my control and one element looks like this: <assignee-id type="integer">38628</assignee-id> it can also look like this: <assig...

Serializing java.lang.Locale

Got a class that serializes into xml with XMLEncoder nicely with all the variables there. Except for the one that holds java.util.Locale. What could be the trick? TIA. ...

How to use Data Access Objects for serialized & relational database data access

Hi all, I am developing a C++ domain model class library which should provide some facilities or a framework (i.e. interface classes etc) for writing/reading class instance data to/from both a binary file and a RDBMS. The basis for this library is an application that uses a RDBMS, and there are several methods which instantiate a class ...

How do you stringize/serialize Ruby code?

I want to be able to write a lambda/Proc in my Ruby code, serialize it so that I can write it to disk, and then execute the lambda later. Sort of like... x = 40 f = lambda { |y| x + y } save_for_later(f) Later, in a separate run of the Ruby interpreter, I want to be able to say... f = load_from_before z = f.call(2) z.should == 42 ...

Stability of .NET serialization across different framework versions

A project I'm working on requires serializing a data structure before shutting down and restores its state from this serialized data when it start up again. Last year, we were building for .NET 1.1, and ran into a tricky issue where our code ran on .NET 2.0 a customer upgraded with some software that somehow set 1.1 as default our cod...

The best way of storing an image/sound inside a class?

I'm developing a kind of an exchange format between instances of an application so that user could save information to file and restore it later. The whole 'exchange format' is a single class that gets serialized and written to disk. How would you suggest to store graphical/sound information inside that class? I'd like to avoid just put...

Easy way to translate from DTO to Entity and Entity to DTO?

I have worked on several distributed client/server projects recently, and one pain point that we always run into is translating the DTO objects into our entities and vice-versa. I was wondering if anyone has a "simple" solution to this time sink? One thing I thought about was coming up with some sort of translation using reflection...I...

Object(Output|Input)Stream binary protocol

I was wondering if anyone had some resources that describe the binary protocol used by ObjectOutputStream. I realize of course that objects themselves can specify what their data by implementing the Externalizable interface, so I guess I'm looking more toward the structure of the object graph - the metadata if you will. I am writing a C...

How to serialize nullable DateTime in a .net web service?

I am trying to pass some Subsonic collections to a client via a web service. When I reference the web service the IDE complains with: Cannot serialize member 'EndDate' of type System.Nullable`1[System.DateTime]. XmlAttribute/XmlText cannot be used to encode complex types. Is there any way of serializing nullable complex types in a .ne...

Best Practice for Loading Object from Serialized XML in C#

Greetings, I have a particular object which can be constructed from a file, as such: public class ConfigObj { public ConfigObj(string loadPath) { //load object using .Net's supplied Serialization library //resulting in a ConfigObj object ConfigObj deserializedObj = VoodooLoadFunction(loadpath); ...

Odd .Net serialization problem

Hello, I had an odd problem today when I was trying to serialize an object. The object was generated via "Add service reference" from a web service (svcutil.exe). The problem was that the below property (agencyId) was not being serialized with the rest of the object. Out of desperation I commented the property below it because it ha...

Serializing and Deserializing Expression Trees in C#

Is there a way to Deserialize Expressions in C#, I would like to store Expressions in a Database and load them at run time. ...

How do I get the contents of an XML element using a XmlSerializer?

I have an XML reader on this XML string: <?xml version="1.0" encoding="UTF-8" ?> <story id="1224488641nL21535800" date="20 Oct 2008" time="07:44"> <title>PRESS DIGEST - PORTUGAL - Oct 20</title> <text> <p> LISBON, Oct 20 (Reuters) - Following are some of the main stories in Portuguese newspapers on Monday. Reuters has not verified t...

C# BinaryFormatter - How can I find out the class of the binary data?

I want to deserialize an object but don't know the class up front. So, consider the following code... IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream("MyFile.bin", FileMode.Open, FileAccess.Read, FileShare.Read); MyObject obj = (MyObject)formatter.Deserialize(stream); What could I do if I don't know the c...

Is implementing java.io.Serializable even in simple POJO Java classes a best practice?

In general, is it a best practice to have simple POJO Java classes implement java.io.Serializable? ...

Distributed Caching Help

I am trying to put some distributed caching into play, I'm using this indeXus.Net Shared Cache . It Requires that the object being cached is serializable, which it is here is the class object. [Serializable] public class Members { public Members() {} public Members(string aspnetusername, string aspnetpassword, str...

C# - Optimising binary serialization for multi-dimensional generic arrays

I have a class that I need to binary serialize. The class contains one field as below: private T[,] m_data; These multi-dimensional arrays can be fairly large (hundreds of thousands of elements) and of any primitive type. When I tried standard .net serialization on an object the file written to disk was large and I think .net is stori...