-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to Create a Mapping file for Queries...........
PostPosted: Sat Jul 14, 2007 3:51 am 
Newbie

Joined: Thu Jul 12, 2007 1:13 am
Posts: 17
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.