开发者

nHibernate 3, sql-query, IndexOutOfRangeException

In my nHibernate mapping, I have something that looks like

<sql-query name="spLogin">
  <return class="User" />
  EXEC dbo.spLogin :username, :password
</sql-query>

The issue is that spLogin doesn开发者_JAVA技巧't return all of the properties of the User entity. If one of the properties is missing, nHibernate throws an IndexOutOfRangeException on the property that doesn't exist in the result set.

Is there a reason why nHibernate can't lazily load this property, if the entity was retrieved as part of a sql-query that didn't return all properties?


16.2.2. Using stored procedures for querying

Have you tried adding <return-property/> elements?

Are the properties you want to lazy-load marked as lazy?


I've been struggling with this same error this morning. It turned out that my return-property elements did not exactly match what came back from the stored proc. Once this was rectified the error went away.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜