user1626506
user1626506

Reputation: 3

Nhibernate throws error No persister for:

Mapping file:

<?xml version="1.0"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"  auto-import="true">
    <class name="PlayHibernate.Employee, PlayHibernate" lazy="false">
        <id name="id" access="field">
            <generator class="native"/>  
        </id>  
        <property name="name" access="field" column="name"/>  
        <many-to-one access="field" name="manager" column="manager" cascade="all"/>  
    </class>
</hibernate-mapping>

I tried setting the mapping file as a resource, but that just changes the error message to "Unhandled Exception: NHibernate.MappingException: PlayHibernate.Employee.hbm.xml (5,31): XML validation error: The element 'id' in namespace 'urn:nhibernate-mapp ing-2.2' cannot contain text. ---> System.Xml.Schema.XmlSchemaValidationExceptio n: The element 'id' in namespace 'urn:nhibernate-mapping-2.2' cannot contain tex t."

Upvotes: 0

Views: 2095

Answers (2)

TagFolks
TagFolks

Reputation: 254

In visual studio remember change the property: "Compilation action" of your .hbm.xml file to : "Embedded resource"

Upvotes: 0

Miroslav Popovic
Miroslav Popovic

Reputation: 12128

The first error "No persister for..." was a consequence of not setting mapping file as an embedded resource.

The current error has something to do with your id definition. It looks like you have some text within your <id> definition. Maybe some unallowed whitespaces? Try to write it as:

<id name="id" access="field" column="uid" generator="native" />

Also if that doesn't help, try to use some other name than id for a field name. Maybe Id.

Upvotes: 3

Related Questions