Results 1 to 2 of 2

Thread: How to Rebuild nHibernate SessionFactory

  1. #1
    Join Date
    Nov 2009
    Posts
    25

    Default How to Rebuild nHibernate SessionFactory

    I am using the NHibernate with Spring.Net. The SessionFactory is created by Spring.Net IOC.
    In my case i need to change the table name to which entity is mapped during runtime. I figured out how to change the table name, but in order for this to take effect we need to rebuild the session factory.

    I tried to get the nHibernate Configuration object by using following method and called BuildSessionFactory method but this throws error couldn't find DBProvider.

    Code:
      LocalSessionFactoryObject f = (LocalSessionFactoryObject)ContextRegistry.GetContext().GetObject("&SessionFactory");
                Configuration config = f.Configuration;
                config.BuildSessionFactory();
    Is there is any API method in Spring.Net to rebuild the NHibernate SessionFactory.

  2. #2
    Join Date
    Jul 2010
    Posts
    245

    Default

    I'd recommend that you consider solving this by having an additional (sep.) session factory for your additional table-name mapping rather than trying to 'swap' it out at runtime.

    -Steve B.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •