Solved

NHibernate Mapping Exception Problem

Posted on 2009-07-14
2
2,314 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
  • 2
2 Comments
 
LVL 2

Author Comment

by:anand_007
Comment Utility
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
Comment Utility
Anyone interested can view the discussion and resoluton here ... https://forum.hibernate.org/viewtopic.php?f=25&t=998315
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now