QuerySyntaxException: Class is not mapped.

699 views
Skip to first unread message

serhatozgel

unread,
Jul 20, 2009, 3:08:49 AM7/20/09
to nhusers
I am receiving this exception from nhibernate when I try to execute
the following line:

session.Delete("From MyClass m");

If I rename any of the fields (e.g. MyID to ID) in my class without
touching the hbm file, this line throws:

NHibernate.PropertyNotFoundException: Could not find a getter for
property 'ID' in class 'MyNamespace.MyClass'.

I am setting up the configuration like this:

var configuration = new Configuration();
configuration.Configure("myconfigfile.hibernate.cfg.xml");
configuration.AddAssembly(typeof(MyClass).Assembly);
configuration.AddAssembly(typeof
(SomeClassInAnotherAssembly).Assembly);
_serverSessionFactory = configuration.BuildSessionFactory();

This is the hbm file I am using:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="MyNamespace"
namespace="MyNamespace">
<class name="MyClass" table="MY_TABLE">
<id name="MyID" column="MY_ID" type="System.String">
<generator class="assigned"></generator>
</id>
<property name="MyList" column="MY_DATA"></property>
</class>
</hibernate-mapping>

And this is the class:

public class MyClass
{
public virtual string MyID { get; set; }
public virtual string MyList { get; set; }
}

I am using nh v2.0.50727. The hbm file is set as embedded resource.
Other classes and mappings in the project work without any problem
with the same settings. Why am I getting this error? How can I find
its cause and fix it?

Tuna Toksoz

unread,
Jul 20, 2009, 12:52:29 PM7/20/09
to nhu...@googlegroups.com
I am assuming that the name of the assembly is MyNamespace?

Tuna Toksöz
Eternal sunshine of the open source mind.

http://devlicio.us/blogs/tuna_toksoz
http://tunatoksoz.com
http://twitter.com/tehlike

Serhat Özgel

unread,
Jul 20, 2009, 3:01:24 PM7/20/09
to nhu...@googlegroups.com
Solved it now. It turns out that I mistyped the class name in the nhibernate query. It is a little embarrassing that I was so sure that nhibernate was giving the wrong error message and I totally blamed the devs for it. Tuna instantly helped, I appreciate his passion for the product.
Reply all
Reply to author
Forward
0 new messages