开发者

Named query not known

开发者 https://www.devze.com 2023-03-23 10:59 出处:网络
I have a mapping in NHibernate like this: <?xml version=\"1.0\" encoding=\"utf-8\"?> <hibernate-mapping namespace=\"News.BusinessEntity\" assembly=\"News.BusinessEntity\" xmlns=\"urn:nhiber

I have a mapping in NHibernate like this:

 <?xml version="1.0" encoding="utf-8"?>
    <hibernate-mapping namespace="News.BusinessEntity" assembly="News.BusinessEntity" xmlns="urn:nhibernate-mapping-2.2">

    <class name="News" table="News">
       <property name="NewsId" type="Int64" column="NewsId"   />
       <property name="NewsTitle" type="String" column="NewsTitle"  />
    </class>

    <sql-query name="Sp_News">
           <return class="News" />
           exec Sp_News
    </sql-query>

</hibernate-m开发者_运维技巧apping>

When I call session.GetNamedQuery("Sp_News") I get the following error:

Named query not known: Sp_News.

Any help would be much appreciated.


the error was solved just by setting the Build Action property of .hbm.xml file to Embeded Resource


The same error is thrown if the mapping file doesn't end with .hbm.xml. I have accidentally renamed a mapping file and dropped the .hbm. from the name, putting it back solved this issue for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消