-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem running NamedQuery
PostPosted: Sat Jul 14, 2007 6:09 am 
Newbie

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

Code:


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 14, 2007 8:03 am 
Beginner
Beginner

Joined: Sun Oct 22, 2006 12:06 pm
Posts: 39
there is a typo in your query
instead of
from Status where status_cd = 1


try

from Status as s where s.statusCd = 1


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

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.