views:

85

answers:

2

I'm looking to persist an object to a single column using NHibernate. I'd like to serialize the data on the way in into a single column, and then deserialize it on the way out. This could be binary or xml. How can I go about doing this?

A: 

Create a property that would implement serialization/deserialization, map that property to the desired column in HBM. Seems simple enough... Where is the trick? :)

+2  A: 

Serialization is the default, if the class is not mapped. You can (should) make it explicit:

<property name="MyProperty" type="Serializeable" />
Stefan Steinegger
Wow, that worked! I didn't realize it was that simple! I was going this roundabout route with a String type and then thinking I had to somehow manage to get someone to serialize it into XML before handing it off to NHibernate... I severely underestimated the framework... THANKS!
noah.blumenthal
@noah: flag it as an answer please.
Frans Bouma