Solved

NHibernate Mapping Exception Problem

Posted on 2009-07-14
2
2,327 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
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Greetings C# program 17 105
HTTPS jquery doesn't work 9 58
Problem!!! 8 33
VB.Net - MemoryMappedFiles - Confirm receipt 2 18
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

785 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