I'm new to nhibernate and fluent nhibernate. For one of our projects we are 
using fluent hibernate which works fine, we would like to extend this to 
support .hbm.xml files mainly to execute stored procedures on legacy 
systems. I've find many articles which helped me for getting started like 
http://robgibbens.blogspot.in/2009/10/nhibernate-sql-query-with-stored.html

But there is an exception encountered while building session factory. 
InnerException: Errors in named queries: {GetMeasures} StackTrae: at 
NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping 
mapping, Settings settings, EventListeners listeners) at 
NHibernate.Cfg.Configuration.BuildSessionFactory() at 
FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()

Here is my configuration Adding Asemblies:

configuration.Mappings(m => m.FluentMappings.AddFromAssembly(mapAssm));
configuration.Mappings(m => m.HbmMappings.AddFromAssembly(mapAssm));  
Here is my *.hbm.xml

     <?xml version="1.0" encoding="utf-8" ?> 
     <hibernate-mapping  xmlns="urn:nhibernate-mapping-2.2" 
auto-import="true"  assembly="MockTest"  namespace="MockTest.Models">
        <sql-query name="GetMeasures" callable ="true">
        <query-param name="Location" type="string" />
        <query-param name="StartDate" type="string" />
        <query-param name="EndDate" type="string" />
        <query-param name="RiskList" type="string" />
       <return class="MockTest.Models.Measures">
         <return-property column="MemberID" name="MemberID" />
         <return-property column="Appointmentid" name="Appointmentid" />
         <return-property column="LastName" name="LastName" />
         <return-property column="FirstName" name="FirstName" />
         <return-property column="MiddleName" name="MiddleName" />
         <return-property column="MeasureData" name="MeasureData" />
     </return>
      exec spGetMeasureValues @Location = :Location,                       
                  
                              @StartDate = :StartDate, 
                              @EndDate = :EndDate, 
                              @RiskList = :RiskList
      </sql-query>
   </hibernate-mapping>
Please let me know is there something wrong with this file? I tried 
wrapping stored procedure  call as following 
 <!CDATA[[exec spGetMeasureValues @Location = :Location, ... ]]> but it 
didn't work

namespace MockTest.Models
 {  public class Measures
    {
      public virtual string MemberID { get; set; }   
      public virtual int Appointmentid { get; set; }    
      public virtual string LastName { get; set; }
      public virtual string FirstName { get; set; }    
      public virtual string MiddleName { get; set; }   
      public virtual string MeasureData { get; set; }
    }
 }


 var query = session.GetNamedQuery("GetMeasures")
                            .SetString("Location", "88")
                            .SetDateTime("StartDate", startDate)
                            .SetDateTime("EndDate", endDate)
                            .SetString("RiskList", "1")
                            .List<Models.Measures>();
                Measures ms = query[0];

Please look into this and provide some inputs.

Thanks
Shravan

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to