title: Named query not known error trying to call a stored proc using Fluent NHibernate
body: <p>I'm working on setting up NHibernate for a project and I have a few queries that, due to their complexity, we will be leaving as stored procedures.  I'd like to be able to use NHibernate to call the sprocs, but have run into an error I can't figure out. Since I'm using Fluent NHibernate I'm using mixed mode mapping as recommended <a href="http://wiki.fluentnhibernate.org/Current_NHibernate_Features_Not_Supported_In_Fluent" rel="noreferrer">here</a>. However, when I run the app I get a "Named query not known: AccountsGetSingle" exception and I can't figure out why. I think I might have a problem with my HBM mapping since I'm not very familiar with using them but I'm not sure.</p>
  
  <p>My NHibernate configuration code is:</p>
  
  <pre><code>private ISessionFactory CreateSessionFactory()
  {
      return Fluently.Configure()
          .Database(MsSqlConfiguration.MsSql2005
              .ConnectionString((conn =&gt; conn.FromConnectionStringWithKey("CIDB")))
                  .ShowSql())
          .Mappings(m =&gt; 
              {
                  m.HbmMappings.AddFromAssemblyOf&lt;Account&gt;();
                  m.FluentMappings.AddFromAssemblyOf&lt;Account&gt;();
              })
          .BuildSessionFactory();
  }
  </code></pre>
  
  <p>My hbm.xml file is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"&gt;
      &lt;sql-query name="AccountsGetSingle"&gt;
          &lt;return alias="Account" class="Core, Account"&gt;&lt;/return&gt;
          exec AccountsGetSingle
      &lt;/sql-query&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>And the code where I am calling the sproc looks like this:</p>
  
  <pre><code>public Account Get()
  {
      return _conversation.Session
          .GetNamedQuery("AccountsGetSingle")
          .UniqueResult&lt;Account&gt;();
  }
  </code></pre>
  
  <p>Any thoughts or ideas would be appreciated. Thanks.</p>
  
  <p><strong>Update:</strong> @kibbled_bits's suggestion get me the end result that I'm looking for (Being able to call a Stored Procedure from NHibernate), but I still don't know why the approach I have listed above doesn't work. I'm still curious as to why since it might provide valuable insight into future problems.</p>