views:

2838

answers:

3

Hi, I've got following hibernate.cfg.xml

<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
<session-factory>
 <property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
 <property name="connection.connection_string">
  User ID=user;Password=password;Data Source=database
</property>
 <property name="show_sql">false</property>
 <property name="dialect">NHibernate.Dialect.Oracle9Dialect</property>
 <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
 <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
</session-factory>

Now I receive following error:

failed: NHibernate.MappingException : Could not compile the mapping document: Mob.Icecube.Data.NH.Mappings.Customer.hbm.xml ----> System.InvalidOperationException : Could not find the dialect in the configuration

Can anyone help me out why he cannot find the driver? Some extra info... It's running at the moment only inside a UnitTest application I added the NHibernate and System.Data.OracleClient to the references of the project Using the latest NHibernate version (2.2 beta)

Thanks in advance

A: 

Do you have the Oracle client installed locally on your pc? I believe this provides some drivers you may need to connect, but I'm not sure. If so, try copying the Oracle.DataAccess.dll file from your installation into the bin folder of your project. This has worked for me in the past.

Mark Struzinski
I do have the client installed but I cannot find the Oracle.DataAccess.dll anywhere on the drive. Then again, I'm using here the data provider given with .NET (System.Data.OracleClient.dll). The error is on the Dialect, not the driver (yet) :D
+3  A: 

There is no NHibernate.Dialect.Oracle9Dialect dialect in the NHibernate assembly.

There is a NHibernate.Dialect.Oracle9iDialect.

Check that your NHibernate config file is being loaded correctly. Use something like:

onfiguration config = new Configuration().Configure("hibernate.cfg.xml").

This is assuming your NHibernate configuration file is called hibernate.cfg.xml and is at the root of your application.

Nigel
Thanks for this answer. After using reflector on the dll, I came to the same constatation... however.Using the Oracle10gDialect or Oracle9iDialect still gives me THE SAME error --> Could not find the dialect in the configuration.There's still something I'm missing I guess that has changed in NHibernate 2.1
Can you post the code where you create the configuration and the session factory?
Nigel
+1  A: 

Hi Nigel. I registered myself now on the site, and it seems that at the moment I'm no longer allowed to leave any comments, so I'll just post the code again in a new answer :D

To create the config and factory: Configuration config = new Configuration(); config.AddAssembly("MyLib.Data.NH"); ISessionFactory factory = config.BuildSessionFactory();

I also changed the config now to use (what should be available) Oracle10gDialect (though I tried 9i as well without success).

<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
    <session-factory name="NHibernate.Test">
     <property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
     <property name="connection.connection_string">
      User ID=user;Password=password;Data Source=db
    </property>
     <property name="show_sql">false</property>
     <property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
     <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
     <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
    </session-factory>
</hibernate-configuration>
Littlefool
I could be wrong, but it looks like you're not processing your NHibernate configuration file, unless you have a section in your web.config. Try replacing Configuration config = new Configuration() and config.AddAssembly("MyLib.Data.NH") with Configuration config = new Configuration().Configure("hibernate.cfg.xml"). This is assuming your NHibernate configuration file is called hibernate.cfg.xml and is at the root of your application.
Nigel
Yep, that's it. I forgot to add config.Configure() first before adding the assembly. Can't believe I wasted a whole day on this (lol). Thank you very much Nigel. Unfortunatly my reputation is too low to upvote your answer.
Littlefool
That's ok, glad to be of help. Come back and tick my answer when you get some reputation ;).
Nigel
In the meantime, I gave you a + 1.
Charlie Flowers