Solved

NHibernate Mapping Exception Problem

Posted on 2009-07-14
2
2,329 Views
Last Modified: 2013-12-17
This is my first NHibernate application. I am trying to follow an NHibernate 1.2 HelloWorld application on VS 2008/SQL Server 2005 RTM/NHibernate 2.1.x. I have a console application and have created a database HelloNHibernate with an Employee table having three columns - ID (int), Name (varchar50), Manager (int). I am trying to add a record through NHibernate but am getting a MappingException was unhandled error. The error says "No persister for: HelloWorldNHibernate.Employee". Inner Exception is null. Gogoling the error threw up two possibilities. One, my mapping file (Employee.hbm.xml) does not have Build Action set to Embedded Resource (this I have set). Second, there must be a syntax error in the hbm file. For the life of me, I can't figure out any problems in the mapping file! Any help is appreciated!  
Employee.hbm.xml:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
	           namespace="HelloWorldNHibernate"
	           assembly="HelloWorldNHibernate">
  <class name="HelloWorldNHibernate.Employee" table="Employee">
        <id name="ID" column="ID">
             <generator class="identity"/>
         </id>
       <property name="Name" column="Name"/>
       <many-to-one access="field" name="Manager" column="Manager" cascade="all"/>
 </class>
</hibernate-mapping>

Open in new window

0
Comment
Question by:anand_007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 2

Author Comment

by:anand_007
ID: 24858120
Ok .. I got the solution! I was using <many-to-one access="field" ...> This was causing a problem. I dropped the access attribute and let it default to property. It now works like a charm :)
0
 
LVL 2

Accepted Solution

by:
anand_007 earned 0 total points
ID: 24867236
Anyone interested can view the discussion and resoluton here ... https://forum.hibernate.org/viewtopic.php?f=25&t=998315
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question