NHibernate Fluent and named Queries

落爺英雄遲暮 提交于 2019-12-04 03:41:49

问题


I am using Nhibernate with fluent. Now I want to call some Stored procedure and use named Queries. I created some xml:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping>
  <sql-query name="CleanAppendicesHierarchies">
    exec intf_CleanUpAppendixHierarchy
  </sql-query>
</hibernate-mapping>

    FluentConfiguration cfg =
    Fluently.Configure().Database(MsSqlConfiguration.MsSql2005.ConnectionString(
c => c.Is(dbConnectionString)).ShowSql())
.Mappings(m => m.FluentMappings.AddFromAssembly(mappingAssembly))
.Mappings(m => m.HbmMappings.AddFromAssembly(mappingAssembly));

Now I got always the Exception:(most inner exception) {"hibernate-mapping xmlns='' was not expected."} {"There is an error in XML document (1, 2)."}

I fiddled around but if I remove hibernate-mapping then it complains about the sql-query tag.

What is wrong in my approach? I googled already found examples but of course with out Fluent....

Any hint is appreciated


回答1:


Strange, I got it working with that:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                   assembly="FactsheetsDataLayer"
                   namespace="FactsheetsDataLayer">  
  <sql-query name="CleanAppendicesHierarchies">
    exec intf_CleanUpAppendixHierarchy
  </sql-query>
</hibernate-mapping>

Then I named the XMl like: POCOClassName.hbm.xml

I do not know what helped but now it worked....



来源:https://stackoverflow.com/questions/1613904/nhibernate-fluent-and-named-queries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!