Currently I am using NHibernate and Fluent mapping for as ORM.

I use named queries to call stored procedures. The named queries are saved in .hbm files.

e.g:

<hibernate-mapping default-cascade="none" 
   xmlns="urn:nhibernate-mapping-2.2" 
   assembly="com.Entities" namespace="com.Entities" >  
   <sql-query name="QUERY_NAME" cacheable="false">
         <return class="FreeText" alias="results" >
            <return-property name="Id" column="FreeTextId"/>
            <return-property name="FreeTextValue" column="FreeText"/>
         </return>
         exec PROC_NAME :PARAM1, :PARAM2  
   </sql-query>    
 </hibernate-mapping>

I wanted to know if there is a way you can define Named Queries in Mapping classes so as to avoid using .hbm file altogether!

有帮助吗?

解决方案

Not possible yet, see https://github.com/jagregory/fluent-nhibernate/wiki/Current-NHibernate-Features-Not-Supported-In-Fluent:

Features not (currently) supported:

  • <sql-insert>
  • <loader>
  • <database-object>
  • <sql-query>
  • Changing Primary Key names (NHibernate limitation as well, currently)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top