每当我使用isession从类调用oracale stordeprocedure时,我发现了一个错误 这是我的mappping文件
<hibernate-mapping
xmlns="urn:nhibernate-mapping-2.2" default-access="field"
assembly="DataContext" namespace="DataContext" >
<sql-query name="GetEmployeedetails" callable="true">
<return alias="emp" class="empdetails" >
<return-property name="U_ID" column="U_ID"/>
<return-property name="IUSR_FIRST_NAME" column="IUSR_FIRST_NAME"/>
<return-property name="IUSR_LAST_NAME" column="IUSR_LAST_NAME"/>
<return-property name="IUSR_EMP_EMAIL_ID" column="IUSR_EMP_EMAIL_ID"/>
<return-property name="IUSR_MOBILE_NO" column="IUSR_MOBILE_NO"/>
<return-property name="IUSR_REMARKS" column="IUSR_REMARKS"/>
<return-property name="IUSR_LOGIN_NAME" column="IUSR_LOGIN_NAME"/>
</return>
{?=call GETEMPLOYEEDETAILS(:pr_page,:pr_userid) }
</sql-query>
</hibernate-mapping>
这是我的班级文件
amespace DataContext
{
public class empdetails
{
public int _ID;
private string _IUSR_FIRST_NAME;
private string _IUSR_LAST_NAME;
private string _IUSR_EMP_EMAIL_ID;
private string _IUSR_MOBILE_NO;
private string _IUSR_REMARKS;
private string _IUSR_LOGIN_NAME;
// private DateTime _IUSR_CREATED_ON;
//public empdetails(int U_ID, string IUSR_FIRST_NAME, string IUSR_LAST_NAME, string IUSR_LOGIN_NAME, string IUSR_EMP_EMAIL_ID, string IUSR_MOBILE_NO, string IUSR_REMARKS)//, DateTime iusrcreated)
//{
// this._ID = U_ID;
// // _IUSR_FIRST_NAME = iusrfname;
// this._IUSR_FIRST_NAME = IUSR_FIRST_NAME;
// this._IUSR_LAST_NAME = IUSR_LAST_NAME;
// this._IUSR_LOGIN_NAME = IUSR_LOGIN_NAME;
// this._IUSR_EMP_EMAIL_ID = IUSR_EMP_EMAIL_ID;
// this._IUSR_MOBILE_NO = IUSR_MOBILE_NO;
// this._IUSR_REMARKS = IUSR_REMARKS;
// // _IUSR_CREATED_ON = iusrcreated;
//}
public empdetails()
{
}
public virtual int U_ID
{
get { return _ID; }
set { _ID = value; }
}
public virtual string IUSR_FIRST_NAME
{
get { return _IUSR_FIRST_NAME; }
set
{
_IUSR_FIRST_NAME = value;
}
}
public virtual string IUSR_LAST_NAME
{
get { return _IUSR_LAST_NAME; }
set
{
_IUSR_LAST_NAME = value;
}
}
public virtual string IUSR_LOGIN_NAME
{
get { return _IUSR_LOGIN_NAME; }
set
{
_IUSR_LOGIN_NAME = value;
}
}
public virtual string IUSR_EMP_EMAIL_ID
{
get { return _IUSR_EMP_EMAIL_ID; }
set
{
_IUSR_EMP_EMAIL_ID = value;
}
}
public virtual string IUSR_MOBILE_NO
{
get { return _IUSR_MOBILE_NO; }
set
{
_IUSR_MOBILE_NO = value;
}
}
public virtual string IUSR_REMARKS
{
get { return _IUSR_REMARKS; }
set
{
_IUSR_REMARKS = value;
}
}
}
我的控制器课程
public ActionResult Index()
{
// OracletestModule ot=new OracletestModule();
//ot.GETEMPDETAILS(17);
//return View(ot);
ISessionFactory factory = new NHibernate.Cfg.Configuration().Configure().BuildSessionFactory();
using (ISession session = factory.OpenSession())
{
var namedQuery = session.GetNamedQuery("GetEmployeedetails");
namedQuery.SetParameter("pr_userid", 17);
// IList list = namedQuery.List();
IList list = (IList)namedQuery.List();
return View();
}
}
oracle存储过程
create or replace
PROCEDURE GETEMPLOYEEDETAILS
(
pr_page out SYS_REFCURSOR,
pr_userid test.U_ID%TYPE
)
AS
BEGIN
open pr_page for
select
U_ID,
IUSR_FIRST_NAME,
IUSR_LAST_NAME,
IUSR_EMP_EMAIL_ID,
IUSR_MOBILE_NO,
IUSR_REMARKS,
IUSR_LOGIN_NAME
from test where U_ID= pr_userid;
END GETEMPLOYEEDETAILS;
PLZ帮助我做错了什么
提前致谢
答案 0 :(得分:0)
当您查询未映射的类时,通常会发生此错误。你有empdetails的映射文件吗?
答案 1 :(得分:0)
我解决了这个问题,删除了由{{1}创建的map.PropertyRef("Id");
ManyToOne
个类中添加到Mapping.ByCode
地图中的所有ClassMapping
}