4.4. NHibernate DAO Session Handler Example Configuration

Similar to the SqlMap implementation, the NHibernate session handler implementation wraps the NHibernate session management services for simple use via the DAO framework. Basically, the properties specified in the configuration are the same as those that would normally be specified in an NHibernate configuration section. Here is an example configuration:

Example 4.3. Example NHibernate DAO Session Handler configuration

<context id="NHibernateDao">
  <properties resource="database.config"/>
    
  <database>
    <provider name="OleDb1.1"/>
    <dataSource name="iBatisNet" 
                connectionString="Provider=SQLOLEDB;Server=${database};database=IBatisNet;
                user id=${userid};password=${password};"/>
  </database>

  <daoSessionHandler id="NHibernate">
    <property name="hibernate.dialect" 
              value="NHibernate.Dialect.MsSql2000Dialect"/>
    <property name="hibernate.connection.provider"
              value="NHibernate.Connection.DriverConnectionProvider"/>
    <property name="hibernate.connection.driver_class" 
              value="NHibernate.Driver.SqlClientDriver"/>
    <property name="mapping" value="IBatisNet.Test"/>
    <property name="show_sql" value="false"/>
    <property name="use_outer_join" value="true"/>
  </daoSessionHandler>

  <daoFactory>
    <dao interface="IBatisNet.Test.Dao.Interfaces.IAccountDao, IBatisNet.Test" 
         implementation="IBatisNet.Test.Dao.Implementations.DataMapper.AccountDao, IBatisNet.Test"/>
  </daoFactory>
</context>