title: NHibernate with nothing but stored procedures
body: <p>I'd like to have NHibernate call a stored procedure when ISession.Get is called to fetch an entity by its key instead of using dynamic SQL.</p>
  
  <p>We have been using NHibernate and allowing it to generate our SQL for queries and inserts/updates/deletes, but now may have to deploy our application to an environment that requires us to use stored procedures for all database access.  We can use sql-insert, sql-update, and sql-delete in our .hbm.xml mapping files for inserts/updates/deletes.  Our hql and criteria queries will have to be replaced with stored procedure calls.</p>
  
  <p>However, I have not figured out how to force NHibernate to use a custom stored procedure to fetch an entity by its key.  I still want to be able to call ISession.Get, as in:</p>
  
  <pre><code>using (ISession session = MySessionFactory.OpenSession())
  {
      return session.Get&lt;Customer&gt;(customerId);
  }
  </code></pre>
  
  <p>and also lazy load objects, but I want NHibernate to call my "GetCustomerById" stored procedure instead of generating the dynamic SQL.</p>
  
  <p>Can this be done?</p>
  
  <p>Perhaps NHibernate is no longer a fit given this new environment we must support. </p>