I'm using NHibernate 1.2.0.GA and my mapping file is this:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHDemo" namespace="NHDemo">
<class
name="Status" table="status">
<id
name="statusCd"
type="long"
column="STATUS_CD"
>
<generator class="assigned" />
</id>
<property
name="statusDesc"
type="String"
column="STATUS_DESC"
length="50"
/>
<property
name="statusId"
type="long"
column="STATUS_ID"
length="18"
/>
</class>
<sql-query name="MyfirstQuery">
<![CDATA[
from Status where status_cd = 1
]]>
</sql-query>
</hibernate-mapping>
I'm trying to run a named query using this the below mentioned code but I'm getting the following exception:An unhandled exception of type 'NHibernate.MappingException' occurred in NHibernate.dll
Additional information: Named query not known: MyfirstQuery
Code:
Configuration conf = new Configuration();
conf.AddXmlFile("Status.hbm.xml");
//conf.AddFile("hibernate.hbm.xml");
ISessionFactory factory = conf.BuildSessionFactory();
ISession session = factory.OpenSession();
session.Flush();
IQuery query = session.GetNamedQuery("MyfirstQuery");
Kindly help me in this Becuase I'm stuck...Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelpHibernate version: Mapping documents:Code between sessionFactory.openSession() and session.close():Full stack trace of any exception that occurs:Name and version of the database you are using:The generated SQL (show_sql=true):Debug level Hibernate log excerpt:Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.htmlCode: