Hi everyone I'm working on a project which have to work on several databases.
To do this I think that the easier is to configure several session factories in the app.config file.
For the moment my first test version is working with this configuration :
App.config:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section
name="nhibernate"
type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"
/>
</configSections>
<nhibernate>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"
/>
<add
key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2000Dialect"
/>
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver"
/>
<add
key="hibernate.connection.connection_string"
value="Password=PWD;Persist Security Info=True;User ID=Login;Initial Catalog=testFactory;Data Source=Server"
/>
</nhibernate>
</configuration>
Everything works with this configuration. Now I Would like to use a session-facory configuration, I First wrote this :
Code:
<configuration>
<configSections>
<section
name="hibernate"
type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"
/>
</configSections>
<hibernate xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Password=PWD;Persist Security Info=True;User ID=LOGIN;Initial Catalog=testFactory;Data Source=SERVER</property>
<property name="connection.isolation">ReadCommitted</property>
<property name="show_sql">false</property>
<property name="use_reflection_optimizer">false</property>
<property name="bytecode.provider">lcg</property>
<mapping assembly="testFactory.Chat, testFactory"/>
</session-factory>
</hibernate>
</configuration>
Guess What... It doesn't work : Dialet not set error.
Like if nhibernate is not loading configuration.
Does someone can explain to me what I did wrong or show me a correct app.config?
Thanks in Advance
P.S: Using Nhibernate 1.2.0
For info here is my Form1.cs code :
Code:
Configuration cfg;
ISessionFactory factory;
cfg = new Configuration();
//cfg.AddFile("Chat.hbm.xml");
cfg.AddAssembly("testFactory");
factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();
Chat c1=new Chat();
c1.Nom="Minou";
session.Save(c1);
transaction.Commit();