NHibernate Fluent and named queries

I use Nhibernate with fluency. 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 always have an Exception: (the innermost exception) {"hibernate-mapping xmlns = '' was not expected." } {"There is an error (1, 2) in the XML document." }

I was messing around, but if I remove hibernate-mapping, it complains about the sql-query tag.

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

Any hint is appreciated

+4
source share
1 answer

Strange, I started working with this:

 <?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 called XMl as follows: POCOClassName.hbm.xml

I don’t know what helped, but now it worked.

+3
source

All Articles