I have the following named SQL query defined:
<sql-query name="ItemSearch">
    <return class="ItemSearchResult">
        <return-property name="Item" column="ItemId" />
        <return-property name="Distance" column="Distance" />
    </return>
    SELECT
        I开发者_开发技巧tems.*,
        dbo.DistanceBetween(Latitude, Longitude, :lat, :long) AS Distance
    FROM Items
    WHERE Contains(Name, :keywords)
    ORDER BY Distance ASC
</sql-query>
Whenever I try to run my application, I get the generic error "Errors in named queries: {ItemSearch}". Is there something obviously wrong here?
The ItemSearchResult class is a very simple wrapper class that looks like this:
public class ItemSearchResult
{
    public Item Item {get; set;}
    public double Distance {get; set;}
}
Do you have a correct .hbm.xml for ItemSearchResult? If you use ItemSearchResult in your query, then you need to have a .hbm.xml for it. Just like entities.
Here is a sample from my code: The only few things that are different between the NHibernate version and my Hibernate is the auto-import and I would assume the package.
<hibernate-mapping auto-import="true" package="PackageName">
  <class name="Name of class to maptop">
    <composite-id>
      <key-property name="<name of parameter>" type="TYPE"/>
    </composite-id>
    <property name="COLUMNNAME" type="TYPE"/>
  </class>
  <sql-query name="queryName">
        <return alias="dr" class="Name of class to map to"/>
select columnName as {dr.nameofColumn}, 
   from table
 </sql-query>
</hibernate-mapping>
I think the problem that exists in your code is that you did not specifically map out the columns and how they map to your class.
Note: If there are any fields that do not correspond to the NHibernate XML format let me know through the comments. I don't have access to my NHibernate mapping files right now.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论