title: how to use a stored procedure in nhibernate
body: <p>Hello
  I try to use stored procedure in nhibernate and I found some methods :</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="CO_Visites_Treeview_Sel"&gt;
      exec CO_Visites_Treeview_Sel :Idclient, :Idmagasin, :Autre, :Tous
    &lt;/sql-query&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>If I want to use the data I will use :</p>
  
  <pre><code>var query = session.GetNamedQuery("CO_Visites_Treeview_Sel");
  query.SetString("Idclient", lstClients.SelectedValue.ToString());
  query.SetInt32("Idmagasin", 36);
  query.SetBoolean("Autre", false);
  query.SetBoolean("Tous", true);
  var results = query.List();
  </code></pre>
  
  <p>In that case I won't have intellisence neither result['colName']</p>
  
  <p>I use another method :</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8" ?&gt;
      &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"&gt;
        &lt;class name="NHibernate.DataAccess.Models.Visites_Treeview,NHibernate.DataAccess" lazy="true"&gt;
          &lt;id name="Idvisite" column="IDVISITE" type="string"&gt;
            &lt;generator class="assigned" /&gt;
          &lt;/id&gt;
          &lt;property column="NOMMAGASIN" name="Nommagasin" type="string" /&gt;
          &lt;property column="DATEVIS" name="Datevis" type="DateTime" /&gt;
          &lt;property column="INTERVENTION" name="Intervention" type="Boolean" /&gt;
          &lt;property column="IDFACTURE" name="Idfacture" type="string" /&gt;
          &lt;property column="STATUT" name="Statut" type="byte" /&gt;
          &lt;property column="NOFACTURE" name="Nofacture" type="int" /&gt;
          &lt;property column="NODEVIS" name="Nodevis" type="int" /&gt;
          &lt;property column="LIVRE" name="Livre" type="Boolean" /&gt;
          &lt;property column="NOCOMMANDE" name="Nocommande" type="int" /&gt;
          &lt;property column="COMPTABILISEE" name="Comptabilisee" type="Boolean" /&gt;
          &lt;property column="RECUP" name="Recup" type="Boolean" /&gt;
          &lt;property column="MASQUE" name="Masque" type="Boolean" /&gt;
        &lt;/class&gt;
        &lt;sql-query name="CO_Visites_Treeview_Sel"&gt;
          &lt;return alias="Visites_Treeview" class="NHibernate.DataAccess.Models.Visites_Treeview,NHibernate.DataAccess"&gt;
            &lt;return-property column="NOMMAGASIN" name="Nommagasin" /&gt;
            &lt;return-property column="IDVISITE" name="Idvisite" /&gt;
            &lt;return-property column="DATEVIS" name="Datevis" /&gt;
            &lt;return-property column="INTERVENTION" name="Intervention" /&gt;
            &lt;return-property column="IDFACTURE" name="Idfacture" /&gt;
            &lt;return-property column="STATUT" name="Statut" /&gt;
            &lt;return-property column="NOFACTURE" name="Nofacture" /&gt;
            &lt;return-property column="NODEVIS" name="Nodevis" /&gt;
            &lt;return-property column="LIVRE" name="Livre" /&gt;
            &lt;return-property column="NOCOMMANDE" name="Nocommande" /&gt;
            &lt;return-property column="COMPTABILISEE" name="Comptabilisee" /&gt;
            &lt;return-property column="RECUP" name="Recup" /&gt;
            &lt;return-property column="MASQUE" name="Masque" /&gt;
          &lt;/return&gt;
          exec CO_Visites_Treeview_Sel :Idclient, :Idmagasin, :Autre, :Tous
        &lt;/sql-query&gt;
      &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>I created a bean class.
  In that case results will have strongly typed object but I have some coherency problem.
  But I have no real identifier so if there is two Idvisite, the second will be ignored.
  I tryed to create a composite key but it doesn't work.</p>
  
  <pre><code>&lt;composite-id&gt;
    &lt;key-property name="Idvisite" column="IDVISITE" type="string" /&gt;
    &lt;key-property name="Idfacture" column="IDFACTURE" type="string" /&gt;
  &lt;/composite-id&gt;
  </code></pre>
  
  <p>And I've an error :</p>
  
  <pre><code>could not execute query
  [ exec CO_Visites_Treeview_Sel @p0, @p1, @p2, @p3 ]
    Name:Idclient - Value:036000004130  Name:Idmagasin - Value:36  Name:Autre - Value:False  Name:Tous - Value:True
  [SQL: exec CO_Visites_Treeview_Sel @p0, @p1, @p2, @p3]
  </code></pre>
  
  <p>Can someone tell me how to do ?</p>
  
  <p>Regards</p>