views:

22

answers:

0

Hello,

I have a class that contains a list of objects, say a list of cars :

class Garage
{
    public virtual List<Car> cars
    {
        get;
        set;
    }
}

The reason I can't directly serialize this list is that the type Car could have a lot of subclasses, and themselves could have other subclasses, and I'd like to avoid updating the database when the hierarchy changes (I'm using a table-per-class implementation).

So a simple trick would be to serialize the list of cars as a string (maybe XML).

But how to make NHibernate aware of that kind of processing :

  • use the object->string processing when persisting in database,
  • use the string->object processing when loading a garage from the database.

I guess NHibernate allows that by using some attributes or some options in the configuration or mapping files, but I haven't find any.

Thanks in advance.