I'm using 1.2.0.GA and have created a table mapping xml App.Config and class for the corresponding table.Now I want to write a HQL query just like as shown below:
<query name="queueSummary.query">
<![CDATA[
select region.hierDesc,market.hierDesc,count(q.queueFilter) ,q.queueFilter
from CustomerLoanQueue as clq,Customer as cust,CustomerHierarchy as chr,
Hierarchy as market,Queue as q,CodeType as ct,Status as status,Hierarchy as region
where clq.status.statusCd = status.statusCd
]]>
</query>
currently I'm using this code but it is not able to find the named query:
Configuration conf = new Configuration();
conf.AddXmlFile("Status.hbm.xml");
//conf.AddFile("query.hbm.xml");
ISessionFactory factory = conf.BuildSessionFactory();
ISession session = factory.OpenSession();
session.Flush();
IQuery query = session.GetNamedQuery("MyfirstQuery");
The mapping File Is given Below:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class
name="NHDemo.Status,NHDemo" 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[
select * from Status where status_cd = 1
]]>
</sql-query>
</hibernate-mapping>
so Kindly tell where should I put this part to use this query in my code.
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate 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.html