Configuration useless.Which are the classes, used in sessionFactory state,
that are not serializable ?

2009/2/5 Tuna Toksoz <[email protected]>

> Yesterday I played with the idea of Serializing the configuration. People
> complain about sessionFactory initialization takes forever and serialization
> is an option most of the time.
> I tried the idea of serializing SessionFactory which wasn't possible since
> it has dependency on many nonserializable classes within NH (and marking
> them as serializable is time consuming).  Instead, I tried serializing
> Configuration right after the buildSessionFactory operation
>
>             BinaryFormatter fm = new BinaryFormatter();
>             Stopwatch sw = Stopwatch.StartNew();
>             FileStream fs = new FileStream("myfile.dat",
> FileMode.OpenOrCreate, FileAccess.Write);
>             Configuration cfg = new Configuration();
>             cfg.Configure();
>             cfg.AddAssembly("DomainWith75EntityClass");
>             cfg.Configure();
>             cfg.BuildSessionFactory();
>             fm.Serialize(fs, cfg);
>             sw.Stop();
>             Console.WriteLine(sw.ElapsedMilliseconds);
>
> before BuildSessionFactory, serialization wasn't possible as
> System.Xml.XmlSchema is nonserializable.
>
> This took 3998 ms
>
> and then I tried
>
>             BinaryFormatter fm = new BinaryFormatter();
>             Stopwatch sw = Stopwatch.StartNew();
>             FileStream fs = new FileStream("myfile.dat", FileMode.Open,
> FileAccess.Read);
>             var cfg = fm.Deserialize(fs) as Configuration;
>             cfg.BuildSessionFactory();
>             sw.Stop();
>             Console.WriteLine(sw.ElapsedMilliseconds);
>
> this took 1578 ms on average.
>
> Should I make Configuration serializable, or do you think it is useless?
>
>
>
> Tuna Toksöz
> http://tunatoksoz.com
> http://twitter.com/tehlike
>
> Typos included to enhance the readers attention!
>
>


-- 
Fabio Maulo

Reply via email to