-1

我的复合主键有问题:我有一个名为“simulateur”的表,复合主键是 Nombre_simulateur 和 Date 类simulateur.hbm.xml:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
  <class name="base_donnee.simulateur, base_donnee" table="simulateur">
 <composite-id >
 <key-property name="Nombre_simulateur">
        <column name="[Nombre_simulateur]" sql-type="int" />
      </key-property>
      <key-property name="Date">
        <column name="[Date]" sql-type="nvarchar(50)" />
      </key-property>
    </composite-id>
    <property name="temps_connection" type="int" />
    <property name="temps_envoi" type="int" />
    <property name="temps_reception" type="int" />
  </class>
</hibernate-mapping>

但是出现异常:Could not compile the mapping document: base_donnee.simulateur.hbm.xml ---> System.InvalidOperationException: Could not find the dialect in the configuration

我的文件 App.config 是:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
  </configSections>
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
      <property name="connection.connection_string_name">Northwind</property>
      <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
      <mapping assembly="base_donnee"/>
    </session-factory>
  </hibernate-configuration>
  <connectionStrings>
    <add name="Northwind" connectionString="Data Source=HP-PC\SQLEXPRESS;Initial Catalog=Simulation; Integrated Security=true" providerName="System.Data.SqlClient"/>

  </connectionStrings>
</configuration>

我需要帮助,有什么想法吗?

4

1 回答 1

2

你可能错过了connection.driver_class

将以下内容添加到您的 web.config:-

...
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
...
于 2012-05-07T07:25:46.747 回答