Hello,
I've got the following mapping for one of my classes :
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="DataTransfer.Category,DataTransfer" table="Category" lazy="true">
<id name="CategoryID" column="CatID" type="int">
<generator class="native" />
</id>
<property name="Description" type="string" column="Description" />
</class>
<sql-query name="sp_NH_GetCategories" callable="true">
<return class="DataTransfer.Category, DataTransfer" >
<return-property name="CategoryID" column="CatID" />
</return>
exec dbo.sp_NH_GetCategories
</sql-query>
</hibernate-mapping>
As you can see the class Category has a Description property which is not returned by the stored procedure. That raises an exception when I try to execute the named query.
Of course I could just return the Description field in my stored procedure and map it, but what if I've got a class with 50 properties, I'm not going to do this for all of them ! Ideally I'd like the named query to return a Category entity with its properties set to the values return by the stored procedure, and if some fields weren't mapped, then they should be null.
Is this possible at all, if so how ?
Thanks