ITPub博客

首页 > IT基础架构 > 网络安全 > NHibernate “login: method get_Upwd should be virtual”错误解答!

NHibernate “login: method get_Upwd should be virtual”错误解答!

原创 网络安全 作者:cheopsen 时间:2008-09-23 10:26:13 0 删除 编辑

错误如下!!

The following types may not be used as proxies:
Entitys.login: method get_Upwd should be virtual
Entitys.login: method get_id should be virtual
Entitys.login: method get_Uname should be virtual
Entitys.login: method set_Uname should be virtual
Entitys.login: method get_LastTime should be virtual
Entitys.login: method set_Upwd should be virtual
Entitys.login: method set_id should be virtual
Entitys.login: method set_LastTime should be virtual

----------------------------------------------------------------------------

引起问题的原因:

NHibernate 1.2 默认为类启用了延迟加载功能

解决方法:

方法1.在映射文件 class 标签中添加 Lazy="false" 属性

例: lazy="false">

方法2.为每个实体类的属性成员 添加 “ virtual ” 修饰符;

例:

public virtual int id
{
get { return m_id; }
set { m_id = value; }
}

----------------------------------------------------------------------------

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/14111848/viewspace-1010938/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论
  • 博文量
    4
  • 访问量
    172546