hi,
i'm new to nhibernate and i have some problems setting up nhibernate.
first, that's what my folder-structure looks like:
second, my Customer.hbm.xml file:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Customer" table="Customer">
<id name="id" column="id" type="int">
<generator class="identity" />
</id>
<property name="name" type="string" column="name"></property>
<property name="vorname" type="string" column="vorname"></property>
</class>
</hibernate-mapping>
third, my Web.Config-File
Code:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.1.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</configSections>
<spring>
<context type="Spring.Context.Support.WebApplicationContext, Spring.Web">
<resource uri="config://spring/objects" />
</context>
<objects xmlns="http://www.springframework.net">
<object name="customerService" type="Service.CustomerService">
<property name="customerDAO" ref="customerDAO"/>
</object>
<object name="customerDAO" type="Dao.CustomerDAO">
<property name="SessionFactory" ref="sessionFactory"/>
</object>
<!--
<object id="dbProvider" type="Spring.Data.Support.MySql, Spring.Data">
<property name="ConnectionString" value="Data Source=localhost;Initial Catalog=test;User Id=root;Password=tutorials"/>
</object>
-->
<object id="sessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate12">
<!--<property name="dbProvider" ref="dbProvider"/>
<property name="HibernateProperties">
<dictionary>
<entry key="" value="" />
<entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
<entry key="hibernate.dialect" value="NHibernate.Dialect.MySQLDialect"/>
<entry key="hibernate.connection.driver_class" value="NHibernate.Driver.MySqlDataDriver"/>
</dictionary>
</property>-->
</object>
<object id="hibernateTransactionManager" type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate12">
<!--<property name="dbProvider" ref="dbProvider"/>-->
<property name="sessionFactory" ref="sessionFactory"/>
</object>
</objects>
</spring>
<nhibernate>
<!-- untenstehendes mit einer klasse im config-ordner -->
<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="Data Source=YOUR_SERVER;Database=Northwind;User ID=YOUR_USERNAME;Password=YOUR_PASSWORD;" />
<add key="hibernate.connection.isolation" value="ReadCommitted" />
<add key="hibernate.default_schema" value="Northwind.dbo" />
[b]<!--<mapping file="Customer.hbm.xml" />-->[/b]
</nhibernate>
<appSettings/>
<connectionStrings/>
<system.web>
<httpHandlers>
<!--<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web" />-->
</httpHandlers>
<httpModules>
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web" />
</httpModules>
<compilation debug="true">
<assemblies>
<add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies>
</compilation>
<authentication mode="Windows"/>
</system.web>
</configuration>
the problem is, that i always get the following error:
Quote:
Server Error in '/testMan' Application.
--------------------------------------------------------------------------------
Unknown entity class: Domain.Customer
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: NHibernate.MappingException: Unknown entity class: Domain.Customer
if i uncomment the following line in the<nhibernate>-section (<!--<mapping file="Customer.hbm.xml" />-->) in the file above (Web.Config) i get the following error:
Quote:
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Unrecognized element.
Source Error:
Line 65: <add key="hibernate.default_schema" value="Northwind.dbo" />
Line 66:
Line 67: <mapping file="Customer.hbm.xml" />
Line 68: </nhibernate>
Line 69:
Source File: D:\testMan\web.config Line: 67
i really don't have an idea what could be wrong. i already asked uncle google and mr. search from hibernate, but i didn't get any reliable answers....
thank you very much for your help.